tests: libxl: Fix a segfault when libxl configuration setup fails

This commit fixes a segmentation fault caused by missing conditional to
check if libxl configuration was properly created by the test. If the
configuration was not properly created, libxlDriverConfigNew() function
will return NULL and cause a segfault at cfg->caps = NULL during the
cleanup.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Julio Faracco 2018-08-02 01:06:39 -03:00 committed by Erik Skultety
parent 3c73beebca
commit 8e09f9afc7

View File

@ -138,7 +138,8 @@ testCompareXMLToDomConfig(const char *xmlfile,
libxl_domain_config_dispose(&actualconfig);
libxl_domain_config_dispose(&expectconfig);
xtl_logger_destroy(log);
cfg->caps = NULL;
if (cfg)
cfg->caps = NULL;
virObjectUnref(cfg);
return ret;
}