Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-02-04 23:31:10 +0100
committerArthur de Jong <arthur@arthurdejong.org>2007-02-04 23:31:10 +0100
commitcc6d169a239d15db41cb0772dbba0ac5c55ba2a5 (patch)
tree320dfe429a384a4b98a2933d0bc7838e65f66ca9 /nslcd
parent72b90a4fdaaac88a8779689e150405fcfaf37c3a (diff)
fix list corruption bug in dict_put() and ignore setting value to NULL
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@235 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd')
-rw-r--r--nslcd/dict.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/nslcd/dict.c b/nslcd/dict.c
index 3ad7c02..84c30d7 100644
--- a/nslcd/dict.c
+++ b/nslcd/dict.c
@@ -90,6 +90,9 @@ DICT *dict_new(void)
int dict_put(DICT *dict,const char *key,void *value)
{
struct dict_entry *entry;
+ /* ignore setting of value to NULL */
+ if (value==NULL)
+ return 0; /* probably do dict_del(dict,key) */
entry=dict_entry_find(dict,key);
if (entry==NULL)
{
@@ -97,12 +100,12 @@ int dict_put(DICT *dict,const char *key,void *value)
entry=dict_entry_new(key);
if (entry==NULL)
return -1;
+ /* insert entry in list */
+ entry->next=dict->head;
+ dict->head=entry;
}
/* set value */
entry->value=value;
- /* insert entry in list */
- entry->next=dict->head;
- dict->head=entry;
return 0;
}