[libvirt] [PATCH] util: Fix memory leak in virJSONParserHandleStartMap

Osier Yang jyang at redhat.com
Thu Jun 23 07:55:38 UTC 2011


---
 src/util/json.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/util/json.c b/src/util/json.c
index db2727d..48521f2 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -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;
-- 
1.7.4




More information about the libvir-list mailing list