From: Ketmar Dark Date: Fri, 8 Apr 2016 19:34:50 +0000 (+0300) Subject: fixed small memory leak in archive reader X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9dc9fb8a1d22fe93e498bc3e1cb7358fdcf5d275;p=d2df-sdl.git fixed small memory leak in archive reader --- diff --git a/src/shared/WADEDITOR.pas b/src/shared/WADEDITOR.pas index de67069..0a80f51 100644 --- a/src/shared/WADEDITOR.pas +++ b/src/shared/WADEDITOR.pas @@ -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