From 677a11ad266ce2f7b8946ea101134a5db2b8f9f1 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 22 Oct 2008 19:39:42 +0000 Subject: [PATCH] ITS#5748: tavl_find3(NULL,,,) returned undefined data --- libraries/liblutil/tavl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/liblutil/tavl.c b/libraries/liblutil/tavl.c index 403fa11f47..d64474fe94 100644 --- a/libraries/liblutil/tavl.c +++ b/libraries/liblutil/tavl.c @@ -448,13 +448,13 @@ tavl_free( Avlnode *root, AVL_FREE dfree ) /* * tavl_find2 - returns Avlnode instead of data pointer. * tavl_find3 - as above, but returns Avlnode even if no match is found. - * also return the last comparison result in ret. + * also set *ret = last comparison result, or -1 if root == NULL. */ Avlnode * tavl_find3( Avlnode *root, const void *data, AVL_CMP fcmp, int *ret ) { - int cmp, dir; - Avlnode *prev; + int cmp = -1, dir; + Avlnode *prev = root; while ( root != 0 && (cmp = (*fcmp)( data, root->avl_data )) != 0 ) { prev = root; -- 2.39.5