From e1702b5a0442013d829eb6e1f4a4c1b7eeb71516 Mon Sep 17 00:00:00 2001 From: Nathan Kinder Date: Fri, 17 Sep 2010 13:31:56 -0700 Subject: 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. --- ldap/servers/slapd/tools/ldclt/scalab01.c | 18 +++++++++++++----- 1 file 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; + } } } } -- cgit