This function can be called over a domain definition that has no
video configured. The
tests/qemuxml2argvdata/qemuxml2argv-minimal.xml file could serve
as an example. Problem is, before the check that domain has some
or none video configured, def->videos is dereferenced causing a
segmentation fault in case there's none video configured.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
virQEMUCapsPtr qemuCaps)
{
size_t i;
- int primaryVideoType = def->videos[0]->type;
+ int primaryVideoType;
if (!def->nvideos) {
/* If we have -device, then we set -nodefaults already */
return 0;
}
+ primaryVideoType = def->videos[0]->type;
+
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY) &&
((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) ||