If qemubinCaps is NULL, then calling virQEMUCapsGetMachineTypesCaps and dereferencing to get the nmachineTypes will cause a core. Rework the code slightly to avoid the issue and return immediately if !qemubinCaps or !nmachineTypes Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index da8f3d1..ee3e50f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2405,10 +2405,13 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, size_t i; *machines = NULL; + *nmachines = 0; + + if (!qemuCaps || !qemuCaps->nmachineTypes) + return 0; *nmachines = qemuCaps->nmachineTypes; - if (*nmachines && - VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0) + if (VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0) goto error; for (i = 0; i < qemuCaps->nmachineTypes; i++) { -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list