If the mapping is not present, we should not try to
access its elements.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 8b5b80f4c5f7342eedce0747469223387ab709ef
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
virJSONValuePtr doc,
qemuFirmwarePtr fw)
{
- virJSONValuePtr mapping = virJSONValueObjectGet(doc, "mapping");
+ virJSONValuePtr mapping;
const char *deviceStr;
int tmp;
+ if (!(mapping = virJSONValueObjectGet(doc, "mapping"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("missing mapping in '%s'"),
+ path);
+ return -1;
+ }
+
if (!(deviceStr = virJSONValueObjectGetString(mapping, "device"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing device type in '%s'"),