mirror of https://gitee.com/openkylin/libvirt.git
qemu: firmware: check virJSONValueObjectGet return value
If the mapping is not present, we should not try to
access its elements.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 8b5b80f4c5
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
a95fc75627
commit
8e12a0b8fa
|
@ -434,10 +434,17 @@ qemuFirmwareMappingParse(const char *path,
|
||||||
virJSONValuePtr doc,
|
virJSONValuePtr doc,
|
||||||
qemuFirmwarePtr fw)
|
qemuFirmwarePtr fw)
|
||||||
{
|
{
|
||||||
virJSONValuePtr mapping = virJSONValueObjectGet(doc, "mapping");
|
virJSONValuePtr mapping;
|
||||||
const char *deviceStr;
|
const char *deviceStr;
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
|
if (!(mapping = virJSONValueObjectGet(doc, "mapping"))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("missing mapping in '%s'"),
|
||||||
|
path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(deviceStr = virJSONValueObjectGetString(mapping, "device"))) {
|
if (!(deviceStr = virJSONValueObjectGetString(mapping, "device"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("missing device type in '%s'"),
|
_("missing device type in '%s'"),
|
||||||
|
|
Loading…
Reference in New Issue