From e227048e66a3215431a6dc9902b540b342f99d44 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Apr 15 2011 21:18:55 +0000 Subject: Bug 697027 - 12 - minor memory leaks found by Valgrind + TET https://bugzilla.redhat.com/show_bug.cgi?id=697027 [Case 12] Description: The caller of valuearray_remove_value is responsible for freeing the removed value. Adding slapi_value_free to free it. --- diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c index a2ae334..6a3a205 100644 --- a/ldap/servers/slapd/valueset.c +++ b/ldap/servers/slapd/valueset.c @@ -399,6 +399,7 @@ valuearray_remove_value_atindex(Slapi_Value **va, int index) * Find the value in the array, * shunt up the array to cover it, * return a ptr to the value. + * The caller is responsible for freeing the value. */ Slapi_Value * valuearray_remove_value(const Slapi_Attr *a, Slapi_Value **va, const Slapi_Value *v) @@ -1043,9 +1044,13 @@ void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s) { Slapi_Value v; + Slapi_Value *removed; value_init(&v,NULL,CSN_TYPE_NONE,NULL); slapi_value_set_string(&v,s); - valuearray_remove_value(a,vs->va,&v); + removed = valuearray_remove_value(a, vs->va, &v); + if(removed) { + slapi_value_free(&removed); + } value_done(&v); }