libxlu: handle NULL pointer in xlu_cfg_destroy
authorOlaf Hering <olaf@aepfle.de>
Thu, 7 May 2015 08:54:26 +0000 (08:54 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 8 May 2015 14:41:57 +0000 (15:41 +0100)
Handle NULL pointer passed to xlu_cfg_destroy. libvirt calls it in its
libxlDriverConfigDispose function. If the XLU_Config was not initialized
yet for some reason a crash would occur on cleanup.
Avoid the crash just like libxl_ctx_free and xtl_logger_destroy do when
called from the same context.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxlu_cfg.c

index 0a59b5283e5c0f117e4866bb2a80c9c7db875bdf..1d709091cbee51e1c98f2a0fe8a0580d5138e496 100644 (file)
@@ -159,6 +159,7 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) {
 void xlu_cfg_destroy(XLU_Config *cfg) {
     XLU_ConfigSetting *set, *set_next;
 
+    if (!cfg) return;
     for (set= cfg->settings;
          set;
          set= set_next) {