aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/third_party/src/kdtree.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/third_party/src/kdtree.c b/src/lib/third_party/src/kdtree.c
index a3a2823c8..4628f7f9e 100644
--- a/src/lib/third_party/src/kdtree.c
+++ b/src/lib/third_party/src/kdtree.c
@@ -160,6 +160,9 @@ static void clear_rec(struct kdnode *node, void (*destr)(void*))
void kd_clear(struct kdtree *tree)
{
+ if (!tree)
+ return;
+
clear_rec(tree->root, tree->destr);
tree->root = 0;
@@ -206,6 +209,9 @@ static int insert_rec(struct kdnode **nptr, const double *pos, void *data, int d
int kd_insert(struct kdtree *tree, const double *pos, void *data)
{
+ if (!tree)
+ return -1;
+
if (insert_rec(&tree->root, pos, data, 0, tree->dim)) {
return -1;
}