TAvgLvlTree: SegFault in "Clear" and "Destroy", if OwnsObjects=true and the Tree is empty
Original Reporter info from Mantis: snoewchen
-
Reporter name: Martin Schneeweis
Original Reporter info from Mantis: snoewchen
- Reporter name: Martin Schneeweis
Description:
See "Additional Information" below (laz_avl_tree.pp - procedure TAVLTree.Clear - I guess it should be sufficient to move the line "DisposeNode(ANode")" into the block above (if ANode<>nil...))
Steps to reproduce:
<code pascal>
program AvgTreeBug;
uses
AvgLvlTree;
Var
Tree: TAvgLvlTree;
begin
Tree := TAvgLvlTree.Create;
Tree.OwnsObjects := True;
Tree.Clear;
[...]
</code pascal>
=> SegFault
Alternatively, a "Tree.Free" also produces a SegFault, if the Tree does not contain any objects.
Additional information:
In laz_avl_tree.pp:
<code pascal>
procedure TAVLTree.Clear;
procedure DeleteNode(ANode: TAVLTreeNode);
begin
if ANode<>nil then begin
[...]
end;
DisposeNode(ANode);
end;
begin
DeleteNode(Root);
[...]
</code pascal>
I guess it should be sufficient to move the line "DisposeNode(ANode")" into the block above (if ANode<>nil...)
Mantis conversion info:
- Mantis ID: 32189
- OS: Arch
- Build: SVN-Commit 55559 (Trunk)
- Platform: Linux
- Version: 1.9 (SVN)
- Fixed in revision: 55561 (#11c15e3b)