mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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 <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ebc241fcff
commit
043b50b948
@ -1472,8 +1472,12 @@ virJSONValueObjectGetStringArray(virJSONValuePtr object, const char *key)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
data = virJSONValueObjectGetArray(object, key);
|
data = virJSONValueObjectGetArray(object, key);
|
||||||
if (!data)
|
if (!data) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("%s is missing or not an array"),
|
||||||
|
key);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
n = virJSONValueArraySize(data);
|
n = virJSONValueArraySize(data);
|
||||||
ret = g_new0(char *, n + 1);
|
ret = g_new0(char *, n + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user