aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2025-01-13 17:31:45 +0100
committerGitHub <noreply@github.com>2025-01-13 17:31:45 +0100
commit8f76b91f6f731e83af439c74a7c99dfcc508fd34 (patch)
treed7bea4051fbfa36e9e19b7fb47492019ae69b13d /src/lib
parent72fd94030142d277d969d1a9cff6e9c4d760cdbb (diff)
fuzz: add 2 new fuzzers for KD-trees and Ball-trees (#2670)
Diffstat (limited to 'src/lib')
-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;
}