From f43f08da92d0162061fa0e3dd91d79d41c8c2f23 Mon Sep 17 00:00:00 2001 From: Mo DeJong Date: Fri, 30 Jun 2017 23:48:39 -0700 Subject: [PATCH] fix issue in kd_res_item3 and kd_res_item3f where pointers should have been compared to NULL --- kdtree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kdtree.c b/kdtree.c index 41cd9c0..2de9b14 100644 --- a/kdtree.c +++ b/kdtree.c @@ -666,9 +666,9 @@ void *kd_res_itemf(struct kdres *rset, float *pos) void *kd_res_item3(struct kdres *rset, double *x, double *y, double *z) { if(rset->riter) { - if(*x) *x = rset->riter->item->pos[0]; - if(*y) *y = rset->riter->item->pos[1]; - if(*z) *z = rset->riter->item->pos[2]; + if (x != NULL) { *x = rset->riter->item->pos[0]; } + if (y != NULL) { *y = rset->riter->item->pos[1]; } + if (z != NULL) { *z = rset->riter->item->pos[2]; } } return 0; } @@ -676,9 +676,9 @@ void *kd_res_item3(struct kdres *rset, double *x, double *y, double *z) void *kd_res_item3f(struct kdres *rset, float *x, float *y, float *z) { if(rset->riter) { - if(*x) *x = rset->riter->item->pos[0]; - if(*y) *y = rset->riter->item->pos[1]; - if(*z) *z = rset->riter->item->pos[2]; + if (x != NULL) { *x = rset->riter->item->pos[0]; } + if (y != NULL) { *y = rset->riter->item->pos[1]; } + if (z != NULL) { *z = rset->riter->item->pos[2]; } } return 0; }