From f7987dfc5745fb6255fdbd2f095f3f17d8a676d6 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Mon, 23 Jul 2007 20:24:33 +0000 Subject: fix a serious bug in dict_values_next() that would return map pointers instead of values and write a test for it git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@315 ef36b2f9-881f-0410-afb5-c4e39611909c --- common/dict.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'common/dict.c') diff --git a/common/dict.c b/common/dict.c index 1b7e787..3aebde7 100644 --- a/common/dict.c +++ b/common/dict.c @@ -148,7 +148,15 @@ void *dict_values_next(DICT *dict) { struct dict_entry *ptr; ptr=dict->ptr; - if (dict->ptr!=NULL) - dict->ptr=dict->ptr->next; - return ptr; + /* search until we get a non-NULL value */ + while ((ptr!=NULL)&&(ptr->value==NULL)) + ptr=ptr->next; + /* we went through the whole list */ + if (ptr==NULL) + { + dict->ptr=NULL; + return NULL; + } + dict->ptr=ptr->next; + return ptr->value; } -- cgit v1.2.3