On a Tuesday in 2020, Michal Privoznik wrote:
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 <mpriv...@redhat.com>
---
src/util/virjson.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/virjson.c b/src/util/virjson.c
index d471923732..160f6172d2 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -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 not an array"),

is missing or not an array

Unless I'm missing something.

Reviewed-by: Ján Tomko <jto...@redhat.com>

Jano

+                       key);
        return NULL;
+    }

    n = virJSONValueArraySize(data);
    ret = g_new0(char *, n + 1);
--
2.26.2

Attachment: signature.asc
Description: PGP signature

Reply via email to