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;
|
FCommentLen: Integer;
|
||||||
FBiff8ExternBooks: TsBiff8ExternBookList;
|
FBiff8ExternBooks: TsBiff8ExternBookList;
|
||||||
FBiff8ExternSheetArray: array of TsBiff8ExternSheet;
|
FBiff8ExternSheetArray: array of TsBiff8ExternSheet;
|
||||||
|
procedure FreeSharedStringTable;
|
||||||
function ReadString(const AStream: TStream; const ALength: Word;
|
function ReadString(const AStream: TStream; const ALength: Word;
|
||||||
out ARichTextParams: TsRichTextParams): String;
|
out ARichTextParams: TsRichTextParams): String;
|
||||||
function ReadUnformattedWideString(const AStream: TStream;
|
function ReadUnformattedWideString(const AStream: TStream;
|
||||||
@ -786,8 +787,8 @@ begin
|
|||||||
SetLength(FBiff8ExternSheetArray, 0);
|
SetLength(FBiff8ExternSheetArray, 0);
|
||||||
FBiff8ExternBooks.Free;
|
FBiff8ExternBooks.Free;
|
||||||
|
|
||||||
{ Destroy shared string table }
|
{ Destroy shared string table, as well as associated rich-text streams}
|
||||||
FSharedStringTable.Free;
|
FreeSharedStringTable;
|
||||||
|
|
||||||
{ Destroy comment list }
|
{ Destroy comment list }
|
||||||
FCommentList.Free;
|
FCommentList.Free;
|
||||||
@ -813,6 +814,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
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.
|
Populates the reader's default palette using the BIFF8 default colors.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
@ -1122,8 +1136,7 @@ begin
|
|||||||
then FCommentList := TObjectList.Create
|
then FCommentList := TObjectList.Create
|
||||||
else FCommentList.Clear;
|
else FCommentList.Clear;
|
||||||
|
|
||||||
if Assigned(FSharedStringTable) then
|
FreeSharedStringTable;
|
||||||
FreeAndNil(FSharedStringTable);
|
|
||||||
|
|
||||||
while (not SectionEOF) do begin
|
while (not SectionEOF) do begin
|
||||||
{ Read the record header }
|
{ Read the record header }
|
||||||
|
Reference in New Issue
Block a user