aboutsummaryrefslogtreecommitdiff
path: root/libarchive/archive_rb.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2013-03-21 18:59:02 +0000
committerMartin Matuska <mm@FreeBSD.org>2013-03-21 18:59:02 +0000
commit6a316f322a46b3e531726dd2a7de63b9e245878d (patch)
tree45c2c8840d99cc81725a3970fd3beee587313cf5 /libarchive/archive_rb.c
parent81418b36c02b6434acd4b8ae4cfb8c80a3742fd4 (diff)
downloadsrc-6a316f322a46b3e531726dd2a7de63b9e245878d.tar.gz
src-6a316f322a46b3e531726dd2a7de63b9e245878d.zip
Notes
Diffstat (limited to 'libarchive/archive_rb.c')
-rw-r--r--libarchive/archive_rb.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libarchive/archive_rb.c b/libarchive/archive_rb.c
index 70bf7e6d3379..5b5da2034497 100644
--- a/libarchive/archive_rb.c
+++ b/libarchive/archive_rb.c
@@ -237,6 +237,8 @@ __archive_rb_tree_reparent_nodes(
struct archive_rb_node * const new_father = old_child;
struct archive_rb_node * const new_child = old_father;
+ if (new_father == NULL)
+ return;
/*
* Exchange descendant linkages.
*/
@@ -552,6 +554,8 @@ __archive_rb_tree_removal_rebalance(struct archive_rb_tree *rbt,
unsigned int other = which ^ RB_DIR_OTHER;
struct archive_rb_node *brother = parent->rb_nodes[other];
+ if (brother == NULL)
+ return;/* The tree may be broken. */
/*
* For cases 1, 2a, and 2b, our brother's children must
* be black and our father must be black
@@ -573,6 +577,8 @@ __archive_rb_tree_removal_rebalance(struct archive_rb_tree *rbt,
*/
__archive_rb_tree_reparent_nodes(parent, other);
brother = parent->rb_nodes[other];
+ if (brother == NULL)
+ return;/* The tree may be broken. */
} else {
/*
* Both our parent and brother are black.
@@ -656,6 +662,8 @@ __archive_rb_tree_removal_rebalance(struct archive_rb_tree *rbt,
* If we had two red nephews, then after the swap,
* our former father would have a red grandson.
*/
+ if (brother->rb_nodes[other] == NULL)
+ return;/* The tree may be broken. */
RB_MARK_BLACK(brother->rb_nodes[other]);
__archive_rb_tree_reparent_nodes(parent, other);
break; /* We're done! */