Commit 11c15e3b authored by ondrej's avatar ondrej
Browse files

avglvltree: fix DisposeNode for nil Node. Issue #32189

git-svn-id: trunk@55561 -
parent 818462b7
......@@ -401,7 +401,7 @@ end;
procedure TAvgLvlTree.DisposeNode(aNode: TAVLTreeNode);
begin
if FOwnsObjects then
if FOwnsObjects and Assigned(aNode) then
begin
TObject(aNode.Data).Free;
aNode.Data := nil;
......
......@@ -624,16 +624,15 @@ procedure TAVLTree.Clear;
procedure DeleteNode(ANode: TAVLTreeNode);
begin
if ANode<>nil then begin
if ANode.Left<>nil then DeleteNode(ANode.Left);
if ANode.Right<>nil then DeleteNode(ANode.Right);
end;
if ANode.Left<>nil then DeleteNode(ANode.Left);
if ANode.Right<>nil then DeleteNode(ANode.Right);
DisposeNode(ANode);
end;
// Clear
begin
DeleteNode(Root);
if Root<>nil then
DeleteNode(Root);
fRoot:=nil;
FCount:=0;
end;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment