Lazarus

Programming => Packages and Libraries => FPSpreadsheet => Topic started by: vincococka on May 13, 2019, 05:01:16 pm

Title: fpsreadsheet SVN 6891: segfault fix
Post by: vincococka on May 13, 2019, 05:01:16 pm
Dear community,

while using latest fpspreadsheet (SVN commit id: 6891) I encountered bug while opening Excel8 workbook (xlsbiff8 in fpsreadsheet sources).
It seems to me that the procedure FreeSharedStringTable should look like this:

procedure TsSpreadBIFF8Reader.FreeSharedStringTable;
var
  j: Integer;
begin
  if not (FSharedStringTable is TStringList) then
    Exit;

  for j := FSharedStringTable.Count-1 downto 0  do
    TObject(FSharedStringTable.Objects[j]).Free;
  FreeAndNil(FSharedStringTable);
end;

Without check "FSharedStringTable is TStringList" it always crashes, which looks like that FSharedStringTable is not initalized correctly.
Shouldn't FSharedStringTable be initialized in TsSpreadBIFF8Reader constructor ?
Title: Re: fpsreadsheet SVN 6891: segfault fix
Post by: wp on May 13, 2019, 05:45:55 pm
Please try r6912. Obviously, the check for FSharedStringTable = nil is missing; it was not needed before r6911 where the method only called FreeAndNil(FSharedStringTable).
Title: Re: fpsreadsheet SVN 6891: segfault fix
Post by: vincococka on May 13, 2019, 06:20:08 pm
Hi,

thanks for quick fix, reading XLS8 works fine with SVN r6912 .

Greets,
  V.