]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testCompareXMLToArgv: Avoid use of uninitialized 'monitor_chr'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 22 Sep 2021 08:52:23 +0000 (10:52 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 Sep 2021 12:48:50 +0000 (14:48 +0200)
Failure of 'testQemuInfoInitArgs' jumps over the initialization of
'monitor_chr' via memset, which leads to a crash.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemuxml2argvtest.c

index f0cfca014c78afa5e49013f36bc364dd8b3476be..675537b05da7bf564d84ade76208fad5b5d896f9 100644 (file)
@@ -642,14 +642,14 @@ testCompareXMLToArgv(const void *data)
     virArch arch = VIR_ARCH_NONE;
     g_autoptr(virIdentity) sysident = virIdentityGetSystem();
 
+    memset(&monitor_chr, 0, sizeof(monitor_chr));
+
     if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
         goto cleanup;
 
     if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
         qemuTestSetHostArch(&driver, info->arch);
 
-    memset(&monitor_chr, 0, sizeof(monitor_chr));
-
     if (!(conn = virGetConnect()))
         goto cleanup;