summaryrefslogtreecommitdiffstats
path: root/src/tree.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-31 18:06:50 +0100
committerDavid Robillard <d@drobilla.net>2020-12-31 20:15:19 +0100
commit585128b152486afd4c2a8811266bdd7cd04c746e (patch)
tree37f62cf9c1bb2089b49914dea4a5454a544f7e4d /src/tree.c
parent2eca87796785d82c4e1da203e87b670236ed7036 (diff)
downloadzix-585128b152486afd4c2a8811266bdd7cd04c746e.tar.gz
zix-585128b152486afd4c2a8811266bdd7cd04c746e.tar.bz2
zix-585128b152486afd4c2a8811266bdd7cd04c746e.zip
Fix potential balance overflow
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tree.c b/src/tree.c
index b0db131..744ced3 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -39,7 +39,7 @@ struct ZixTreeNodeImpl {
struct ZixTreeNodeImpl* left;
struct ZixTreeNodeImpl* right;
struct ZixTreeNodeImpl* parent;
- int_fast8_t balance;
+ int balance;
};
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
@@ -445,7 +445,7 @@ zix_tree_remove(ZixTree* t, ZixTreeIter* ti)
ZixTreeNode* const n = ti;
ZixTreeNode** pp = NULL; // parent pointer
ZixTreeNode* to_balance = n->parent; // lowest node to balance
- int8_t d_balance = 0; // delta(balance) for n->parent
+ int d_balance = 0; // delta(balance) for n->parent
DEBUG_PRINTF("*** REMOVE %ld\n", (intptr_t)n->data);
@@ -573,10 +573,10 @@ zix_tree_remove(ZixTree* t, ZixTreeIter* ti)
if (i->parent) {
if (i == i->parent->left) {
- d_balance = (uint8_t)height_change * -1;
+ d_balance = height_change * -1;
} else {
assert(i == i->parent->right);
- d_balance = (uint8_t)height_change;
+ d_balance = height_change;
}
}
}