DEADSOFTWARE

fixed small memory leak in archive reader
authorKetmar Dark <ketmar@ketmar.no-ip.org>
Fri, 8 Apr 2016 19:34:50 +0000 (22:34 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Fri, 8 Apr 2016 19:34:50 +0000 (22:34 +0300)
src/shared/WADEDITOR.pas

index de670694b81fe44207506b355c7351b3921ea86c..0a80f51d4d43091f3be64900719c3180a498e588 100644 (file)
@@ -157,6 +157,7 @@ var
   f: Integer;
   fi: TSFSFileInfo;
   fs: TStream;
+  fpp: Pointer;
   //fn: string;
 begin
   Result := False;
@@ -186,8 +187,19 @@ begin
       end;
       Len := Integer(fs.size);
       GetMem(pData, Len);
-      fs.ReadBuffer(pData^, Len);
-      fs.Free;
+      fpp := pData;
+      try
+        fs.ReadBuffer(pData^, Len);
+        fpp := nil;
+      finally
+        if fpp <> nil then
+        begin
+          FreeMem(fpp);
+          pData := nil;
+          Len := 0;
+        end;
+        fs.Free;
+      end;
       result := true;
       {$IFDEF SFS_DWFAD_DEBUG}
       if gSFSDebug then