]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix memory leak in openvz_conf.c
authorPavel Hrdina <phrdina@redhat.com>
Mon, 13 Jan 2014 13:33:15 +0000 (14:33 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 15 Jan 2014 10:11:34 +0000 (11:11 +0100)
If there is no error while executing a function "openvzParseBarrierLimit"
a "str" string where is duplicate of a "value" string isn't freed and it
leads into memory leak.

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/openvz/openvz_conf.c

index 0dbaa4a8779b70945d8219821ba8aab9d55bf44f..91b16f8aedf565b621e3cdfe9d43e435f14fe3d2 100644 (file)
@@ -136,6 +136,7 @@ openvzParseBarrierLimit(const char* value,
     char *token;
     char *saveptr = NULL;
     char *str;
+    int ret = -1;
 
     if (VIR_STRDUP(str, value) < 0)
         goto error;
@@ -158,10 +159,10 @@ openvzParseBarrierLimit(const char* value,
                 goto error;
         }
     }
-    return 0;
+    ret = 0;
 error:
     VIR_FREE(str);
-    return -1;
+    return ret;
 }