summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2014-01-05 14:47:30 +0100
committerArthur de Jong <arthur@arthurdejong.org>2014-01-05 15:04:46 +0100
commit8e74848cff12ea9902c59081515d46fc51d6f545 (patch)
treea6700006b538b09a6944b8d5a53a760711e0bfe5 /tests
parent328894237b24e50b8d39f1fe85f9fa7e2d37e5de (diff)
Fix memory leaks related to set_pop()
Some pieces of code did not properly free() the value returned by set_pop(). The leak in group code was related to the introduction of nested group functionality in 41ba574 (merged in 3daa68d) so should only be present in releases 0.9.0 forward. The leak in the netgroup code only ended up in the Solaris version of the NSS module and was introduced in 4ea9ad1 (merged in 5c8779d). This leak is present in all releases from 0.8.0 forward.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_set.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/test_set.c b/tests/test_set.c
index d2525be..c68e9c9 100644
--- a/tests/test_set.c
+++ b/tests/test_set.c
@@ -2,7 +2,7 @@
test_set.c - simple test for the set module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
+ Copyright (C) 2008-2014 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -43,6 +43,7 @@ int main(int UNUSED(argc), char UNUSED(*argv[]))
SET *set;
const char **list;
int i;
+ const char *v;
/* initialize */
set = set_new();
@@ -68,9 +69,12 @@ int main(int UNUSED(argc), char UNUSED(*argv[]))
}
/* remove keys from the set */
- assert(isknownvalue(set_pop(set)));
- assert(isknownvalue(set_pop(set)));
- assert(isknownvalue(set_pop(set)));
+ assert(isknownvalue(v = set_pop(set)));
+ free((void *)v);
+ assert(isknownvalue(v = set_pop(set)));
+ free((void *)v);
+ assert(isknownvalue(v = set_pop(set)));
+ free((void *)v);
assert(set_pop(set) == NULL);
/* free set */