diff options
author | Brad King <brad.king@kitware.com> | 2013-07-26 20:08:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-07-31 12:19:13 (GMT) |
commit | 102071f80cf4ad7aa97bf8a1618cfc6ee6689ab6 (patch) | |
tree | db05ed527f04506957049a7b087be6c038d98435 /Utilities/cmlibarchive/libarchive/archive_rb.c | |
parent | 87402c995ed2460deb2f39e02acf77a0bb57f263 (diff) | |
parent | 35df7c8ba8854e97bd6994c4d1143f57535ed6f2 (diff) | |
download | CMake-102071f80cf4ad7aa97bf8a1618cfc6ee6689ab6.zip CMake-102071f80cf4ad7aa97bf8a1618cfc6ee6689ab6.tar.gz CMake-102071f80cf4ad7aa97bf8a1618cfc6ee6689ab6.tar.bz2 |
Merge branch 'libarchive-upstream' into update-libarchive
Conflicts:
Utilities/cmlibarchive/CMakeLists.txt
Utilities/cmlibarchive/libarchive/archive.h
Utilities/cmlibarchive/libarchive/archive_entry.h
Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
Utilities/cmlibarchive/libarchive/archive_windows.h
Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
Diffstat (limited to 'Utilities/cmlibarchive/libarchive/archive_rb.c')
-rw-r--r-- | Utilities/cmlibarchive/libarchive/archive_rb.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_rb.c b/Utilities/cmlibarchive/libarchive/archive_rb.c index f8035d9..5b5da20 100644 --- a/Utilities/cmlibarchive/libarchive/archive_rb.c +++ b/Utilities/cmlibarchive/libarchive/archive_rb.c @@ -96,7 +96,7 @@ __archive_rb_tree_init(struct archive_rb_tree *rbt, const struct archive_rb_tree_ops *ops) { rbt->rbt_ops = ops; - *((const struct archive_rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE; + *((struct archive_rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE; } struct archive_rb_node * @@ -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. */ @@ -377,13 +379,13 @@ __archive_rb_tree_swap_prune_and_rebalance(struct archive_rb_tree *rbt, if (standin_father == self) { /* - * As a child of self, any childen would be opposite of + * As a child of self, any children would be opposite of * our parent. */ standin_son = standin->rb_nodes[standin_which]; } else { /* - * Since we aren't a child of self, any childen would be + * Since we aren't a child of self, any children would be * on the same side as our parent. */ standin_son = standin->rb_nodes[standin_other]; @@ -410,7 +412,7 @@ __archive_rb_tree_swap_prune_and_rebalance(struct archive_rb_tree *rbt, /* * If we are about to delete the standin's father, then when * we call rebalance, we need to use ourselves as our father. - * Otherwise remember our original father. Also, sincef we are + * Otherwise remember our original father. Also, since we are * our standin's father we only need to reparent the standin's * brother. * @@ -466,7 +468,7 @@ __archive_rb_tree_swap_prune_and_rebalance(struct archive_rb_tree *rbt, * __archive_rb_tree_node_swap(rbt, self, which); * __archive_rb_tree_prune_node(rbt, self, F); * - * But it's more efficient to just evalate and recolor the child. + * But it's more efficient to just evaluate and recolor the child. */ static void __archive_rb_tree_prune_blackred_branch( @@ -505,7 +507,7 @@ __archive_rb_tree_remove_node(struct archive_rb_tree *rbt, * red-black tree. So if we must remove a node, attempt to rearrange * the tree so we can remove a red node. * - * The simpliest case is a childless red node or a childless root node: + * The simplest case is a childless red node or a childless root node: * * | T --> T | or | R --> * | * | s --> * | @@ -517,7 +519,7 @@ __archive_rb_tree_remove_node(struct archive_rb_tree *rbt, } if (!RB_TWOCHILDREN_P(self)) { /* - * The next simpliest case is the node we are deleting is + * The next simplest case is the node we are deleting is * black and has one red child. * * | T --> T --> T | @@ -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! */ @@ -683,7 +691,7 @@ __archive_rb_tree_iterate(struct archive_rb_tree *rbt, */ if (RB_SENTINEL_P(self->rb_nodes[direction])) { while (!RB_ROOT_P(rbt, self)) { - if (other == RB_POSITION(self)) + if (other == (unsigned int)RB_POSITION(self)) return RB_FATHER(self); self = RB_FATHER(self); } |