Browse Source

* moved the check in FloodFill whether x,y are within the current viewport in
the beginning, before any heap memory allocations, to avoid memory leaks when
FloodFill is invoked with a point that is outside the current viewport

git-svn-id: trunk@40965 -

nickysn 6 years ago
parent
commit
92304ce573
1 changed files with 2 additions and 2 deletions
  1. 2 2
      packages/graph/src/inc/fills.inc

+ 2 - 2
packages/graph/src/inc/fills.inc

@@ -434,6 +434,8 @@ var
    BackupColor : ColorType;
    x1, x2, prevy: smallint;
   Begin
+    If (x<0) Or (y<0) Or
+       (x>ViewWidth) Or (y>ViewHeight) then Exit;
     GetMem(DrawnList,sizeof(PFloodLine)*((ViewHeight div YResDiv) + 1));
     if not assigned(DrawnList) then
       begin
@@ -466,8 +468,6 @@ var
         _GraphResult := grNoFloodMem;
         exit;
       end;
-    If (x<0) Or (y<0) Or
-       (x>ViewWidth) Or (y>ViewHeight) then Exit;
     { Index of points to check  }
     Buffer.WordIndex:=0;
     PushPoint (x,y);