tests: Check for virQEMUDriverConfigNew return value

The function may return NULL if something went wrong. In some places
in the tests we are not checking the return value rather than
accessing the pointer directly resulting in SIGSEGV.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2015-01-26 17:09:36 +01:00
parent b54f48812d
commit c6ec7c6b0b
3 changed files with 7 additions and 2 deletions

View File

@ -231,6 +231,9 @@ mymain(void)
virQEMUDriverConfigPtr cfg = virQEMUDriverConfigNew(false);
if (!cfg)
return EXIT_FAILURE;
# define DO_TEST_QEMU(Filename, QemuCapsFile, Emulatorbin, Machine, Arch, Type, ...) \
do { \
const char *capsPath = abs_srcdir "/qemucapabilitiesdata/" QemuCapsFile ".caps"; \

View File

@ -348,7 +348,8 @@ mymain(void)
virEventRegisterDefaultImpl();
driver.config = virQEMUDriverConfigNew(false);
if (!(driver.config = virQEMUDriverConfigNew(false)))
return EXIT_FAILURE;
VIR_FREE(driver.config->spiceListen);
VIR_FREE(driver.config->vncListen);
/* some dummy values from 'config file' */

View File

@ -211,7 +211,8 @@ mymain(void)
if (!abs_top_srcdir)
abs_top_srcdir = abs_srcdir "/..";
driver.config = virQEMUDriverConfigNew(false);
if (!(driver.config = virQEMUDriverConfigNew(false)))
return EXIT_FAILURE;
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver)))