* tests/testutilsqemu.c (testQemuCapsInit): Initialize variables.
---
Gcc on F12 caught this, sorry I didn't catch it in the review:
- if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
+ if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL ||
+ (machines = testQemuAllocMachines(&nmachines)) == NULL)
goto cleanup;
This change meant that we could then use machines inside the
cleanup: label without having initialized it; freeing uninitialized
data is never a good idea, even it if is unlikely to have happened.
I'm pushing it under the obvious rule, since it breaks builds with
--enable-compiler-warnings=error.
tests/testutilsqemu.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index e0e5e14..7fee21a 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -58,8 +58,8 @@ virCapsPtr testQemuCapsInit(void) {
struct utsname utsname;
virCapsPtr caps;
virCapsGuestPtr guest;
- virCapsGuestMachinePtr *machines;
- int nmachines;
+ virCapsGuestMachinePtr *machines = NULL;
+ int nmachines = 0;
static const char *const xen_machines[] = {
"xenner"
};
--
1.6.6.1