]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Fix memory leak in virJSONParserHandleStartMap
authorOsier Yang <jyang@redhat.com>
Thu, 23 Jun 2011 10:16:31 +0000 (18:16 +0800)
committerOsier Yang <jyang@redhat.com>
Thu, 23 Jun 2011 10:16:31 +0000 (18:16 +0800)
src/util/json.c

index db2727d848f6c06a706a32c1e9a41efbda5ff5c3..48521f2ccb2c3e1803b62165139c216bed352103 100644 (file)
@@ -799,8 +799,10 @@ static int virJSONParserHandleStartMap(void *ctx)
     }
 
     if (VIR_REALLOC_N(parser->state,
-                      parser->nstate + 1) < 0)
+                      parser->nstate + 1) < 0) {
+        virJSONValueFree(value);
         return 0;
+    }
 
     parser->state[parser->nstate].value = value;
     parser->state[parser->nstate].key = NULL;