open-vm-tools/SOURCES/ovt-Fix-memory-leak-in-SNEBuildHash-function.patch
2021-09-09 23:20:50 +00:00

53 lines
2.0 KiB
Diff

From ce0aed0b753b24891cf33463f69e0ceb953b826f Mon Sep 17 00:00:00 2001
From: Cathy Avery <cavery@redhat.com>
Date: Thu, 25 Jul 2019 12:32:28 +0200
Subject: [PATCH 05/16] Fix memory leak in SNEBuildHash function.
RH-Author: Cathy Avery <cavery@redhat.com>
Message-id: <20190725123239.18274-6-cavery@redhat.com>
Patchwork-id: 89716
O-Subject: [RHEL8.1 open-vm-tools PATCH 05/16] Fix memory leak in SNEBuildHash function.
Bugzilla: 1602648
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
commit 1b755d3e619ed40d8750532f10af5a1df6de6cda
Author: Oliver Kurth <okurth@vmware.com>
Date: Tue Apr 30 13:24:24 2019 -0700
Fix memory leak in SNEBuildHash function.
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.
Signed-off-by: Cathy Avery <cavery@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
open-vm-tools/lib/system/systemLinux.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/system/systemLinux.c b/lib/system/systemLinux.c
index c74d489..7d9798a 100644
--- a/lib/system/systemLinux.c
+++ b/lib/system/systemLinux.c
@@ -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);
--
1.8.3.1