fpspreadsheet: Fix memory leak in cell memory allocation (visibile in OOXML and ODS).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3462 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-08-09 14:17:49 +00:00
parent dd08f3e7c1
commit ced21b2d9c

View File

@ -1574,12 +1574,15 @@ end;
procedure TsWorksheet.RemoveCallback(data, arg: pointer); procedure TsWorksheet.RemoveCallback(data, arg: pointer);
begin begin
Unused(arg); Unused(arg);
(*
{ The strings and dyn arrays must be reset to nil content manually, because { The strings and dyn arrays must be reset to nil content manually, because
FreeMem only frees the record mem, without checking its content } FreeMem only frees the record mem, without checking its content }
PCell(data).UTF8StringValue := ''; PCell(data).UTF8StringValue := '';
PCell(data).NumberFormatStr := ''; PCell(data).NumberFormatStr := '';
SetLength(PCell(data).RPNFormulaValue, 0); SetLength(PCell(data).RPNFormulaValue, 0);
FreeMem(data); // FreeMem(data);
*)
Dispose(PCell(data));
end; end;
function CompareCells(Item1, Item2: Pointer): Integer; function CompareCells(Item1, Item2: Pointer): Integer;
@ -1952,7 +1955,8 @@ begin
if (Result = nil) then if (Result = nil) then
begin begin
Result := GetMem(SizeOf(TCell)); New(Result);
// Result := GetMem(SizeOf(TCell));
FillChar(Result^, SizeOf(TCell), #0); FillChar(Result^, SizeOf(TCell), #0);
Result^.Row := ARow; Result^.Row := ARow;
@ -6660,7 +6664,8 @@ end;
} }
function NewRPNItem: PRPNItem; function NewRPNItem: PRPNItem;
begin begin
Result := GetMem(SizeOf(TRPNItem)); New(Result);
// Result := GetMem(SizeOf(TRPNItem));
FillChar(Result^.FE, SizeOf(Result^.FE), 0); FillChar(Result^.FE, SizeOf(Result^.FE), 0);
Result^.FE.StringValue := ''; Result^.FE.StringValue := '';
end; end;
@ -6671,8 +6676,11 @@ end;
procedure DisposeRPNItem(AItem: PRPNItem); procedure DisposeRPNItem(AItem: PRPNItem);
begin begin
if AItem <> nil then begin if AItem <> nil then begin
{
AItem.FE.StringValue := '';; AItem.FE.StringValue := '';;
FreeMem(AItem, SizeOf(TRPNItem)); FreeMem(AItem, SizeOf(TRPNItem));
}
Dispose(AItem);
end; end;
end; end;