]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix memory leak in SNEBuildHash function.
authorOliver Kurth <okurth@vmware.com>
Tue, 30 Apr 2019 20:24:24 +0000 (13:24 -0700)
committerOliver Kurth <okurth@vmware.com>
Tue, 30 Apr 2019 20:24:24 +0000 (13:24 -0700)
In a specific code path of the SNEBuildHash function, when the
environment variable is of the format VMWARE_*=[0|1], the value
is not freed.  Fixed the memory leak.

open-vm-tools/lib/system/systemLinux.c

index c74d48901d9993821f811cf857f91c05b09ca691..7d9798ab71b331f0f48c8fa9a2b6d6cd00d9989d 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -607,6 +607,8 @@ SNEBuildHash(const char **compatEnviron)
          char *realValue = (value[0] == '0')
                            ? NULL
                            : Util_SafeStrdup(&value[1]);
+         free(value);
+         value = NULL;
          HashTable_ReplaceOrInsert(environTable, realKey, realValue);
       } else {
          HashTable_LookupOrInsert(environTable, key, value);