Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/common/dict.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-07-23 22:24:33 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-07-23 22:24:33 +0200
commitf7987dfc5745fb6255fdbd2f095f3f17d8a676d6 (patch)
treea95c9cab0f5ff68483fd3db4d4a43073462129b1 /common/dict.c
parente77242bf31acba871ca3fcaab8cfb808d363262c (diff)
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
Diffstat (limited to 'common/dict.c')
-rw-r--r--common/dict.c14
1 files changed, 11 insertions, 3 deletions
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;
}