You've already forked lazarus-ccr
fpspreadsheet: Fix memory leak due to rich-text streams in shared string table when reading biff8. Issue #35528, modified patch by Jurijs Romanovs.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6891 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -124,6 +124,7 @@ type
|
||||
FCommentLen: Integer;
|
||||
FBiff8ExternBooks: TsBiff8ExternBookList;
|
||||
FBiff8ExternSheetArray: array of TsBiff8ExternSheet;
|
||||
procedure FreeSharedStringTable;
|
||||
function ReadString(const AStream: TStream; const ALength: Word;
|
||||
out ARichTextParams: TsRichTextParams): String;
|
||||
function ReadUnformattedWideString(const AStream: TStream;
|
||||
@ -786,8 +787,8 @@ begin
|
||||
SetLength(FBiff8ExternSheetArray, 0);
|
||||
FBiff8ExternBooks.Free;
|
||||
|
||||
{ Destroy shared string table }
|
||||
FSharedStringTable.Free;
|
||||
{ Destroy shared string table, as well as associated rich-text streams}
|
||||
FreeSharedStringTable;
|
||||
|
||||
{ Destroy comment list }
|
||||
FCommentList.Free;
|
||||
@ -813,6 +814,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Frees the shared string table. Also: destroys the rich-text memory streams
|
||||
which can be assigned to string table items.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF8Reader.FreeSharedStringTable;
|
||||
var
|
||||
j: Integer;
|
||||
begin
|
||||
for j := 0 to FSharedStringTable.Count-1 do
|
||||
TObject(FSharedStringTable.Objects[j]).Free;
|
||||
FreeAndNil(FSharedStringTable);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Populates the reader's default palette using the BIFF8 default colors.
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -1122,8 +1136,7 @@ begin
|
||||
then FCommentList := TObjectList.Create
|
||||
else FCommentList.Clear;
|
||||
|
||||
if Assigned(FSharedStringTable) then
|
||||
FreeAndNil(FSharedStringTable);
|
||||
FreeSharedStringTable;
|
||||
|
||||
while (not SectionEOF) do begin
|
||||
{ Read the record header }
|
||||
|
Reference in New Issue
Block a user