From 03d3dea65021fe19b2fc5b1df2b956226828ec89 Mon Sep 17 00:00:00 2001 From: Andreas Hoenselaar Date: Thu, 16 Sep 2021 17:11:19 -0700 Subject: [PATCH] Correctly deallocate memory in `destroy_geom_box_tree` 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 --- utils/geom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/geom.c b/utils/geom.c index 1ecd221..ea4b352 100644 --- a/utils/geom.c +++ b/utils/geom.c @@ -1359,7 +1359,7 @@ void destroy_geom_box_tree(geom_box_tree t) { if (t) { destroy_geom_box_tree(t->t1); destroy_geom_box_tree(t->t2); - if (t->nobjects && t->objects) FREE(t->objects); + if (t->objects) FREE(t->objects); FREE1(t); } }