index c9af0bd7fd68617801c85d2caaf6310ed83bf2bb..0a80f51d4d43091f3be64900719c3180a498e588 100644 (file)
--- a/src/shared/WADEDITOR.pas
+++ b/src/shared/WADEDITOR.pas
f: Integer;
fi: TSFSFileInfo;
fs: TStream;
+ fpp: Pointer;
//fn: string;
begin
Result := False;
if not isOpen or (fIter = nil) then Exit;
if length(Resource) = 0 then Exit; // just in case
if (length(Section) <> 0) and (Section[length(Section)] <> '/') then Section := Section+'/';
- for f := 0 to fIter.Count-1 do
+ // backwards, due to possible similar names and such
+ for f := fIter.Count-1 downto 0 do
begin
fi := fIter.Files[f];
if fi = nil then continue;
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