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