From c94352a1313aa606fc38c0ed7f6c9dc1c698c62b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 4 Nov 2022 23:48:43 -0700 Subject: libix2: fix depth maintenance precedence *depth-- should be (*depth)-- etc. surprisingly this went unnoticed for some time but I haven't really been using libix[23] in anything other than sars which didn't get much play/testing etc. But a quick ASAN run immediately uncovered this one. --- src/ix2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ix2.c b/src/ix2.c index e87cf2c..da02f07 100644 --- a/src/ix2.c +++ b/src/ix2.c @@ -368,7 +368,7 @@ static ix2_object_t * add_object(ix2_t *ix2, unsigned *depth, ix2_node_t *node, bb2f_t quadrants[4]; int i; - *depth++; + (*depth)++; init_quadrants(quadrants, node_aabb, &node->center); for (i = 0; i < 4; i++) { if (!aabb_overlap(NULL, NULL, &quadrants[i], &object->position, &object->origin, &object->aabb)) @@ -377,7 +377,7 @@ static ix2_object_t * add_object(ix2_t *ix2, unsigned *depth, ix2_node_t *node, if (!add_object(ix2, depth, &node->children[i], &quadrants[i], object, reference_cache)) goto _fail; } - *depth--; + (*depth)--; return object; } @@ -388,10 +388,10 @@ static ix2_object_t * add_object(ix2_t *ix2, unsigned *depth, ix2_node_t *node, /* If the node is overflowing, split it */ if (node->n_objects > ix2->max_per_node && *depth < ix2->max_depth) { - *depth++; + (*depth)++; if (!split_node(ix2, depth, node, node_aabb)) goto _fail; - *depth--; + (*depth)--; } return object; -- cgit v1.2.3