]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virconf: Resolve a possible memory leak in virConfSetValue
authorJohn Ferlan <jferlan@redhat.com>
Fri, 9 Jan 2015 13:42:13 +0000 (08:42 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 12 Jan 2015 13:59:55 +0000 (08:59 -0500)
Found this one by inspection... The API claims to "own" the input
value even in the case of error.  However, in the initial entry
to the API if the value exists, was STRING, but without a str value
it just returned without freeing the 'value' which it claims to now
own.  So I added the virConfFreeValue() call in order to resolve.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virconf.c

index b1509feea7b8a0f9bc61cbbf00322bb58f0addbe..01e5a6aa7046a1f43cb585493993a057661642a5 100644 (file)
@@ -887,8 +887,10 @@ virConfSetValue(virConfPtr conf,
 {
     virConfEntryPtr cur, prev = NULL;
 
-    if (value && value->type == VIR_CONF_STRING && value->str == NULL)
+    if (value && value->type == VIR_CONF_STRING && value->str == NULL) {
+        virConfFreeValue(value);
         return -1;
+    }
 
     cur = conf->entries;
     while (cur != NULL) {