Browse Source

Fixed segfaults on lines 178 and 176

Cameron Weinfurt 5 months ago
parent
commit
5d216ff450
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      tree_alloc.c

+ 2
- 2
tree_alloc.c View File

@@ -169,7 +169,7 @@ void replace_node(TreeAlloc **root_ptr, TreeAlloc *node, TreeAlloc *replace) {
169 169
 		else 
170 170
 			node->parent->right = replace;
171 171
 	}
172
-	if (!replace) replace->parent = node->parent;
172
+	if (replace) replace->parent = node->parent;
173 173
 }
174 174
 
175 175
 void repair_after_remove(TreeAlloc **root_ptr, TreeAlloc *node) {
@@ -242,7 +242,7 @@ void remove_node(TreeAlloc **root_ptr, TreeAlloc *node) {
242 242
 		node->left->parent = tmp;
243 243
 	}
244 244
 
245
-	if (do_repair) {
245
+	if (do_repair && replace) {
246 246
 		repair_after_remove(root_ptr, replace);
247 247
 	}
248 248
 }

Loading…
Cancel
Save