From 8e09f9afc712712f8a4747c69836800a11a6f6f3 Mon Sep 17 00:00:00 2001 From: Julio Faracco Date: Thu, 2 Aug 2018 01:06:39 -0300 Subject: [PATCH] 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 Reviewed-by: Erik Skultety --- tests/libxlxml2domconfigtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 34a63e22b5..a9758c40cb 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -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; } -- GitLab