From 0ed8797df2cfdb2b9374246ce68bd21ee9d7bbf3 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 13 Feb 2013 16:01:25 +0100 Subject: [PATCH] Add sanity check to AVL tree, fix #597 --- base/src/base/avl_tree/avl_tree.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/src/base/avl_tree/avl_tree.cc b/base/src/base/avl_tree/avl_tree.cc index 77fc4ab80..5758ae186 100644 --- a/base/src/base/avl_tree/avl_tree.cc +++ b/base/src/base/avl_tree/avl_tree.cc @@ -117,6 +117,9 @@ void Avl_node_base::remove(Policy &policy) Avl_node_base *lp = 0; Avl_node_base *l = _child[0]; + if (!_parent) + PERR("Error: tried to remove AVL node that is not in an AVL tree"); + if (l) { /* find right-most node in left sub tree (l) */ @@ -157,6 +160,10 @@ void Avl_node_base::remove(Policy &policy) lpp->_rebalance_subtree(lp, policy); lp = lpp; } + + /* reset node pointers */ + _child[LEFT] = _child[RIGHT] = 0; + _parent = 0; }