talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit b77707343f62ed124c5481d013181be90fca84a0
parent fb0fb9d311c6d716111c11dc5f8684ccaef9e3fe
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Wed, 12 Jul 2017 13:22:52 +0200

Fixed a few memory leaks in LDAP search results handling.

Diffstat:
Msrc/ldapctrl.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/ldapctrl.c b/src/ldapctrl.c @@ -629,15 +629,18 @@ char **ldapctl_full_attribute_array( LdapControl *ctl ) { } def = ldapctl_get_default_criteria_list(); + node = def; - while (def) { + while (node) { if( g_list_find_custom(tmp, (gpointer)def->data, (GCompareFunc)strcmp2) == NULL) { - tmp = g_list_append(tmp, g_strdup(def->data)); + tmp = g_list_append(tmp, g_strdup(node->data)); } - def = def->next; + node = node->next; } + g_list_free_full(def, g_free); + node = tmp; cnt = g_list_length( tmp ); ptrArray = g_new0( char *, 1 + cnt); @@ -660,6 +663,7 @@ void ldapctl_free_attribute_array( char **ptrArray ) { /* Clear array to NULL's */ for( i = 0; ptrArray[i] != NULL; i++ ) { + g_free(ptrArray[i]); ptrArray[i] = NULL; } g_free( ptrArray ); @@ -747,8 +751,7 @@ GList *ldapctl_get_default_criteria_list() { else item = g_strdup(criteria); debug_print("adding attribute to list: %s\n", item); - attr_list = g_list_append(attr_list, g_strdup(item)); - g_free(item); + attr_list = g_list_append(attr_list, item); } g_strfreev(c_list); return attr_list;