From: Michal Privoznik Date: Tue, 1 Dec 2020 11:10:34 +0000 (+0100) Subject: virJSONValueObjectGetStringArray: Report error if @key is not an array X-Git-Tag: v7.0.0-rc1~385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=043b50b948ef3c2;p=thirdparty%2Flibvirt.git virJSONValueObjectGetStringArray: Report error if @key is not an array 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 Reviewed-by: Ján Tomko --- diff --git a/src/util/virjson.c b/src/util/virjson.c index d471923732..4f92464421 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 or not an array"), + key); return NULL; + } n = virJSONValueArraySize(data); ret = g_new0(char *, n + 1);