From: Oliver Kurth Date: Mon, 9 Sep 2019 18:23:49 +0000 (-0700) Subject: Fix Misc. issues in vmtoolsLog.c X-Git-Tag: stable-11.1.0~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d3607ca69fb031cd1b25c157a396250a867cf3e;p=thirdparty%2Fopen-vm-tools.git Fix Misc. issues in vmtoolsLog.c * g_malloc0 aborts the application if the specificed amount of memory cannot be allocated. Hence, no need to have a NULL check for the return value of g_malloc0. * Removed one if block in VMToolsLogInt since the if check will never be TRUE. * g_strdup returns NULL if the input argument is NULL. Removed the unnecessary NULL checks for the input argument to g_strdup at few places. --- diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index 6c83f7646..3259d84ca 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -610,14 +610,9 @@ VMToolsLogInt(const gchar *domain, data = data->inherited ? gDefaultData : data; entry = g_malloc0(sizeof(LogEntry)); - if (entry) { - entry->domain = domain ? g_strdup(domain) : NULL; - if (domain && !entry->domain) { - VMToolsLogPanic(); - } - entry->handler = data; - entry->level = level; - } + entry->domain = g_strdup(domain); + entry->handler = data; + entry->level = level; if (gLogIOSuspended && data->needsFileIO) { if (gMaxCacheEntries == 0) { @@ -1016,7 +1011,7 @@ VMToolsGetLogHandler(const gchar *handler, logger->type = strdup(handler); logger->needsFileIO = needsFileIO; logger->isSysLog = isSysLog; - logger->confData = (path != NULL ? g_strdup(path) : NULL); + logger->confData = g_strdup(path); g_free(path); return logger;