Allocate the hash table only after the log file is opened so that we
don't need to deallocate it on failure.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
break;
}
logger.logDir = logDir;
- logger.files = virHashNew(libxlLoggerFileFree);
path = g_strdup_printf("%s/libxl-driver.log", logDir);
- if ((logger.defaultLogFile = fopen(path, "a")) == NULL) {
- virHashFree(logger.files);
+ if ((logger.defaultLogFile = fopen(path, "a")) == NULL)
return NULL;
- }
+
+ logger.files = virHashNew(libxlLoggerFileFree);
return XTL_NEW_LOGGER(libvirt, logger);
}