mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
libxlLoggerNew: Avoid virHashFree by rearranging code
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>
This commit is contained in:
parent
35ebb28f3f
commit
04bbaa2b1f
@ -149,14 +149,13 @@ libxlLoggerNew(const char *logDir, virLogPriority minLevel)
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user