ldap/servers/slapd/valueset.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
New commits:
commit c51c77b302f0e7ed2df32de54385295090ae6c85
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 15 14:18:55 2011 -0700
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);
}