]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virJSONValueObjectGetStringArray: Report error if @key is not an array
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Dec 2020 11:10:34 +0000 (12:10 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Dec 2020 16:21:14 +0000 (17:21 +0100)
The virJSONValueObjectGetStringArray() function is given a @key
which is supposed to be an array inside given @object. Well, if
it's not then an error state is returned (NULL), but no error
message is set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virjson.c

index d4719237327637581b130da528065de96689f2b2..4f92464421720c77603b2846e0de5ffd4a30a3e4 100644 (file)
@@ -1472,8 +1472,12 @@ virJSONValueObjectGetStringArray(virJSONValuePtr object, const char *key)
     size_t i;
 
     data = virJSONValueObjectGetArray(object, key);
-    if (!data)
+    if (!data) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("%s is missing or not an array"),
+                       key);
         return NULL;
+    }
 
     n = virJSONValueArraySize(data);
     ret = g_new0(char *, n + 1);