View Issue Details

IDProjectCategoryView StatusLast Update
0032189LazarusLazUtilspublic2017-07-23 17:10
ReporterMartin Schneeweis Assigned ToOndrej Pokorny  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSArch 
Product Version1.9 (SVN) 
Summary0032189: TAvgLvlTree: SegFault in "Clear" and "Destroy", if OwnsObjects=true and the Tree is empty
DescriptionSee "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 InformationIn 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...)

 
TagsNo tags attached.
Fixed in Revision55561
LazTarget-
Widgetset
Attached Files

Activities

Juha Manninen

2017-07-23 10:30

developer   ~0101860

Could you please create a proper patch.
 http://wiki.freepascal.org/Creating_A_Patch

Issue History

Date Modified Username Field Change
2017-07-23 08:22 Martin Schneeweis New Issue
2017-07-23 10:30 Juha Manninen Note Added: 0101860
2017-07-23 16:58 Ondrej Pokorny Assigned To => Ondrej Pokorny
2017-07-23 16:58 Ondrej Pokorny Status new => assigned
2017-07-23 17:10 Ondrej Pokorny Fixed in Revision => 55561
2017-07-23 17:10 Ondrej Pokorny LazTarget => -
2017-07-23 17:10 Ondrej Pokorny Status assigned => resolved
2017-07-23 17:10 Ondrej Pokorny Resolution open => fixed