Browse Source

fpPDF: fix memory leak in TPDFImages.AddFromStream for KeepImage=True

git-svn-id: trunk@43471 -
ondrej 5 years ago
parent
commit
2f244383be
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/fcl-pdf/src/fppdf.pp

+ 4 - 2
packages/fcl-pdf/src/fppdf.pp

@@ -3213,10 +3213,12 @@ begin
       Reader.Free;
       Reader.Free;
     end;
     end;
     IP.Image:=I;
     IP.Image:=I;
-    if Not KeepImage then
+    if KeepImage then
+      IP.OwnsImage := True
+    else
       begin
       begin
       IP.CreateStreamedData(Owner.ImageStreamOptions);
       IP.CreateStreamedData(Owner.ImageStreamOptions);
-      IP.FImage:=Nil; // not through property, that would clear the image
+      IP.DetachImage; // not through property, that would clear the image
       i.Free;
       i.Free;
       end;
       end;
   end;
   end;