Skip to content

Commit 21aff7e

Browse files
authored
Correctly deallocate memory in destroy_geom_box_tree (#58)
If `nobjects` is zero, then MALLOC is still called during the construction of the tree. However, `malloc` implementations can choose to return a non-NULL pointer in that case and the returned pointer should be freed in order to prevent leaks: https://en.cppreference.com/w/c/memory/malloc
1 parent 245f732 commit 21aff7e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

utils/geom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ void destroy_geom_box_tree(geom_box_tree t) {
13591359
if (t) {
13601360
destroy_geom_box_tree(t->t1);
13611361
destroy_geom_box_tree(t->t2);
1362-
if (t->nobjects && t->objects) FREE(t->objects);
1362+
if (t->objects) FREE(t->objects);
13631363
FREE1(t);
13641364
}
13651365
}

0 commit comments

Comments
 (0)