On 3/6/26 11:46, Elizaveta Tereshkina wrote:
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..72bd78453a 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); + virJSONValueFree(ret); return NULL; }
There's one more occurrence under 'json_type_object' case. I'll fix that too. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and merged. Congratulations on your first libvirt contribution! Michal