From: Oliver Kurth Date: Tue, 12 Nov 2019 02:12:22 +0000 (-0800) Subject: Fix a potentisl memory leak in an error situation; reported by Coverity. X-Git-Tag: stable-11.1.0~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce3919d77f15395f048f839bfdb4c60cf6c6794;p=thirdparty%2Fopen-vm-tools.git Fix a potentisl memory leak in an error situation; reported by Coverity. --- diff --git a/open-vm-tools/services/plugins/deployPkg/deployPkg.c b/open-vm-tools/services/plugins/deployPkg/deployPkg.c index 449ad093c..9085a9fb8 100644 --- a/open-vm-tools/services/plugins/deployPkg/deployPkg.c +++ b/open-vm-tools/services/plugins/deployPkg/deployPkg.c @@ -400,6 +400,7 @@ DeployPkgGetTempDir(void) free(newDir); if (!Random_Crypto(sizeof(randIndex), &randIndex)) { g_warning("%s: Random_Crypto failed\n", __FUNCTION__); + newDir = NULL; goto exit; } newDir = Str_Asprintf(NULL, "%s%s%08x%s", @@ -412,9 +413,10 @@ DeployPkgGetTempDir(void) i++; } - if (found == FALSE) { + if (!found) { g_warning("%s: could not create temp directory\n", __FUNCTION__); - goto exit; + free(newDir); + newDir = NULL; } exit: free(dir);