diff --git a/src/scip/rbtree.c b/src/scip/rbtree.c index 37ee2562a6..520367657c 100644 --- a/src/scip/rbtree.c +++ b/src/scip/rbtree.c @@ -359,7 +359,11 @@ void SCIPrbtreeInsert_call( SCIP_RBTREENODE* node /**< node to insert into the tree */ ) { - SET_PARENT(node, parent); + /* we avoid SET_PARENT here, as this would read from uninitialized memory in an attempt to preserve the color of node */ + node->parent = (uintptr_t)parent | RED; + node->child[LEFT] = NULL; + node->child[RIGHT] = NULL; + if( parent == NULL ) *root = node; else if( pos > 0 ) @@ -367,8 +371,5 @@ void SCIPrbtreeInsert_call( else parent->child[RIGHT] = node; - node->child[LEFT] = NULL; - node->child[RIGHT] = NULL; - MAKE_RED(node); rbInsertFixup(root, node); } diff --git a/src/scip/rbtree.h b/src/scip/rbtree.h index fe38eee2b0..38b1cf0a6c 100644 --- a/src/scip/rbtree.h +++ b/src/scip/rbtree.h @@ -61,7 +61,7 @@ struct SCIP_RBTreeNode */ #define SCIP_RBTREE_HOOKS SCIP_RBTREENODE _rbtreenode -/* convenience macros that automtically cast the given arguments to SCIP_RBTREENODE */ +/* convenience macros that automatically cast the given arguments to SCIP_RBTREENODE */ #define SCIPrbtreeFirst(root) SCIPrbtreeFirst_call((SCIP_RBTREENODE*)(root)) #define SCIPrbtreeLast(root) SCIPrbtreeLast_call((SCIP_RBTREENODE*)(root)) #define SCIPrbtreeSuccessor(x) SCIPrbtreeSuccessor_call((SCIP_RBTREENODE*)(x))