Browse Source

* Fix for bug ID #0022986

git-svn-id: trunk@22460 -
michael 13 years ago
parent
commit
2cd78c03b3
1 changed files with 24 additions and 21 deletions
  1. 24 21
      packages/fcl-image/src/fpreadpng.pp

+ 24 - 21
packages/fcl-image/src/fpreadpng.pp

@@ -742,27 +742,30 @@ procedure TFPReaderPNG.DoDecompress;
         end
         end
       else
       else
         l := ScanLineLength[rp]*ByteWidth;
         l := ScanLineLength[rp]*ByteWidth;
-      GetMem (FPreviousLine, l);
-      GetMem (FCurrentLine, l);
-      fillchar (FCurrentLine^,l,0);
-      try
-        for ry := 0 to CountScanlines[rp]-1 do
-          begin
-          FSwitchLine := FCurrentLine;
-          FCurrentLine := FPreviousLine;
-          FPreviousLine := FSwitchLine;
-          Y := CalcY(ry);
-          Decompress.Read (lf, sizeof(lf));
-          Decompress.Read (FCurrentLine^, l);
-          if lf <> 0 then  // Do nothing when there is no filter used
-            for rx := 0 to l-1 do
-              FCurrentLine^[rx] := DoFilter (lf, rx, FCurrentLine^[rx]);
-          HandleScanLine (y, FCurrentLine);
-          end;
-      finally
-        freemem (FPreviousLine);
-        freemem (FCurrentLine);
-      end;
+      if (l>0) then
+        begin
+        GetMem (FPreviousLine, l);
+        GetMem (FCurrentLine, l);
+        fillchar (FCurrentLine^,l,0);
+        try
+          for ry := 0 to CountScanlines[rp]-1 do
+            begin
+            FSwitchLine := FCurrentLine;
+            FCurrentLine := FPreviousLine;
+            FPreviousLine := FSwitchLine;
+            Y := CalcY(ry);
+            Decompress.Read (lf, sizeof(lf));
+            Decompress.Read (FCurrentLine^, l);
+            if lf <> 0 then  // Do nothing when there is no filter used
+              for rx := 0 to l-1 do
+                FCurrentLine^[rx] := DoFilter (lf, rx, FCurrentLine^[rx]);
+            HandleScanLine (y, FCurrentLine);
+            end;
+        finally
+          freemem (FPreviousLine);
+          freemem (FCurrentLine);
+        end;
+        end;
       end;
       end;
   end;
   end;