From 9ca52d7be8835cbca3e55df6fba26c6a0dea8b19 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 8 Jul 2020 23:14:31 -0400 Subject: Fix check for null sub trees before setting parent during map rotation --- collections/map/map.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/collections/map/map.c b/collections/map/map.c index a1c7798..c217fa2 100644 --- a/collections/map/map.c +++ b/collections/map/map.c @@ -50,6 +50,12 @@ struct map_node **node; tmp->right = (*node)->left; (*node)->left = tmp; + (*node)->parent = (*node)->left->parent; + (*node)->left->parent = *node; + + if ((*node)->left->right) + (*node)->left->right->parent = (*node)->left; + return; } @@ -63,6 +69,12 @@ struct map_node **node; tmp->left = (*node)->right; (*node)->right = tmp; + (*node)->parent = (*node)->right->parent; + (*node)->right->parent = *node; + + if ((*node)->right->left) + (*node)->right->left->parent = (*node)->right; + return; } -- cgit v1.1