summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-09-17 13:31:56 -0700
committerNathan Kinder <nkinder@redhat.com>2010-09-17 13:31:56 -0700
commite1702b5a0442013d829eb6e1f4a4c1b7eeb71516 (patch)
tree37a28b77d9c2533dca8cfa618dd019bbe76276e9
parent2af08b37e8bcebb68ad85c8cc6195f8f6d3403f1 (diff)
downloadds-e1702b5a0442013d829eb6e1f4a4c1b7eeb71516.tar.gz
ds-e1702b5a0442013d829eb6e1f4a4c1b7eeb71516.tar.xz
ds-e1702b5a0442013d829eb6e1f4a4c1b7eeb71516.zip
Bug 630092 - (cov#12116) Resource leak in ldclt code
There is a chance that we leak the memory pointed to by the new variable if we never have one of the ldclt contexts point to it. We need to jump to the error label in this case to free the memory.
-rw-r--r--ldap/servers/slapd/tools/ldclt/scalab01.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ldap/servers/slapd/tools/ldclt/scalab01.c b/ldap/servers/slapd/tools/ldclt/scalab01.c
index c0437b08..39345bd1 100644
--- a/ldap/servers/slapd/tools/ldclt/scalab01.c
+++ b/ldap/servers/slapd/tools/ldclt/scalab01.c
@@ -465,6 +465,13 @@ scalab01_addLogin (
else
{
cur = s1ctx.list;
+
+ /* If cur is NULL, we should just bail and free new. */
+ if (cur == NULL)
+ {
+ goto error;
+ }
+
while (cur != NULL)
{
if (cur->next == NULL)
@@ -472,15 +479,16 @@ scalab01_addLogin (
cur->next = new;
cur = NULL; /* Exit loop */
}
- else
- if (cur->next->counter >= duration)
- {
+ else if (cur->next->counter >= duration)
+ {
new->next = cur->next;
cur->next = new;
cur = NULL; /* Exit loop */
- }
- else
+ }
+ else
+ {
cur = cur->next;
+ }
}
}
}