diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-07-23 22:24:33 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-07-23 22:24:33 +0200 |
commit | f7987dfc5745fb6255fdbd2f095f3f17d8a676d6 (patch) | |
tree | a95c9cab0f5ff68483fd3db4d4a43073462129b1 /common/dict.c | |
parent | e77242bf31acba871ca3fcaab8cfb808d363262c (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.c | 14 |
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; } |