[libvirt PATCH 2/3] util: json: check return value of virJSONValueFromJsonC

Ján Tomko posted 3 patches 3 weeks, 6 days ago
There is a newer version of this series
[libvirt PATCH 2/3] util: json: check return value of virJSONValueFromJsonC
Posted by Ján Tomko 3 weeks, 6 days ago
In virJSONValueFromJsonC, the return value of virJSONValueFromJsonC
was not checked in one case.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/virjson.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/util/virjson.c b/src/util/virjson.c
index 18a4585e7b..a799707c16 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -1437,6 +1437,11 @@ virJSONValueFromJsonC(json_object *jobj)
 
             cur = virJSONValueFromJsonC(val);
 
+            if (!cur) {
+                g_free(ret);
+                return NULL;
+            }
+
             virJSONValueArrayAppend(ret, &cur);
         }
         break;
-- 
2.47.0