diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-10 17:20:45 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-10 17:20:45 +0000 |
commit | 49d36abbea370bc540d02b232ee5198f25a1386c (patch) | |
tree | afe216a9d36f8e37cb61ca42b3f0e6347fc5a7e8 | |
parent | e6700ff8bafec2bb45743264b8b29376fc98fd00 (diff) | |
download | ATCD-49d36abbea370bc540d02b232ee5198f25a1386c.tar.gz |
fixed dangling pointer bug
-rw-r--r-- | ChangeLog-99b | 6 | ||||
-rw-r--r-- | ace/RB_Tree.cpp | 38 |
2 files changed, 35 insertions, 9 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 49715903866..79a9ef9a0db 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,3 +1,9 @@ +Mon May 10 12:14:00 1999 Chris Gill <cdgill@cs.wustl.edu> + + * ace/RB_Tree.cpp: fixed a dangling pointer bug in + RB_Tree::delete_fixup. Added pointer tests to all + dereferences in this piece of code. + Mon May 10 11:35:18 1999 Ossama Othman <othman@cs.wustl.edu> * COPYING: diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp index 2abb9cfcbcb..51ce070f278 100644 --- a/ace/RB_Tree.cpp +++ b/ace/RB_Tree.cpp @@ -276,14 +276,23 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tre (!w->right () || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { - w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + if (w->left ()) + { + w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + } w->color (ACE_RB_Tree_Node_Base::RED); RB_rotate_right (w); w = x->parent ()->right (); } - w->color (x->parent ()->color ()); + if (w) + { + w->color (x->parent ()->color ()); + if (w->right ()) + { + w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); + } + } x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); RB_rotate_left (x->parent ()); x = root_; } @@ -299,7 +308,8 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tre w = x->parent ()->left (); } // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if ((!w->left () || + if (w && + (!w->left () || w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) && (!w->right () || w->right ()->color () == ACE_RB_Tree_Node_Base::BLACK)) @@ -310,17 +320,27 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tre else { // CLR pp. 263 says that nil nodes are implicitly colored BLACK - if (!w->left () || - w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK) + if (w && + (!w->left () || + w->left ()->color () == ACE_RB_Tree_Node_Base::BLACK)) { - w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); w->color (ACE_RB_Tree_Node_Base::RED); + if (w->right ()) + { + w->right ()->color (ACE_RB_Tree_Node_Base::BLACK); + } RB_rotate_left (w); w = x->parent ()->left (); } - w->color (x->parent ()->color ()); + if (w) + { + w->color (x->parent ()->color ()); + if (w->left ()) + { + w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); + } + } x->parent ()->color (ACE_RB_Tree_Node_Base::BLACK); - w->left ()->color (ACE_RB_Tree_Node_Base::BLACK); RB_rotate_right (x->parent ()); x = root_; } |