From 616882cf2ad7fabff3805113d00d5f14606c6e95 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 24 Jul 2014 14:45:22 +1000 Subject: [PATCH] ckdb - abort on NULL tree in ktree find functions --- src/ktree.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ktree.c b/src/ktree.c index e3e66ea7..0518e29d 100644 --- a/src/ktree.c +++ b/src/ktree.c @@ -558,6 +558,9 @@ K_ITEM *find_in_ktree(K_TREE *ktree, K_ITEM *data, double (*cmp_funct)(K_ITEM *, { double cmp = -1.0; + if (ktree == NULL) + FAIL("%s", "%K_TREE-F-FINDNULL find ktree is NULL"); + while (ktree->isNil == No && cmp != 0.0) { if ((cmp = (*cmp_funct)(ktree->data, data))) @@ -586,6 +589,9 @@ K_ITEM *find_after_in_ktree(K_TREE *ktree, K_ITEM *data, double (*cmp_funct)(K_I K_TREE *old = NULL; double cmp = -1.0, oldcmp = -1; + if (ktree == NULL) + FAIL("%s", "%K_TREE-F-FINDNULL find_after ktree is NULL"); + while (ktree->isNil == No && cmp != 0.0) { if ((cmp = (*cmp_funct)(ktree->data, data))) @@ -628,6 +634,9 @@ K_ITEM *find_before_in_ktree(K_TREE *ktree, K_ITEM *data, double (*cmp_funct)(K_ K_TREE *old = NULL; double cmp = 1.0, oldcmp = 1; + if (ktree == NULL) + FAIL("%s", "%K_TREE-F-FINDNULL find_before ktree is NULL"); + while (ktree->isNil == No && cmp != 0.0) { if ((cmp = (*cmp_funct)(ktree->data, data)))