In the 'json_type_array' case, the error path uses 'g_free()',
which doesn't release other nested memory allocations.
Replace it with 'virJSONValueFree()' to properly free
the entire 'virJSONValue' structure.
Fixes: da66bf53b0 (util: json: check return value of virJSONValueFromJsonC)
Signed-off-by: Elizaveta Tereshkina <teryoshkina.ea@gmail.com>
---
src/util/virjson.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 454bd657be..5780dbb094 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -1438,7 +1438,7 @@ virJSONValueFromJsonC(json_object *jobj)
cur = virJSONValueFromJsonC(val);
if (!cur) {
- g_free(ret);
+ virJSONValue(ret);
return NULL;
}
--
2.39.2