|
|
0d097b |
From 4bc0c2c7833dd643fc1137daf6519670c05c3736 Mon Sep 17 00:00:00 2001
|
|
|
0d097b |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
0d097b |
Date: Thu, 23 Jan 2020 21:11:16 +0100
|
|
|
0d097b |
Subject: [PATCH 21/23] sss_ptr_hash: fixed memory leak
|
|
|
0d097b |
MIME-Version: 1.0
|
|
|
0d097b |
Content-Type: text/plain; charset=UTF-8
|
|
|
0d097b |
Content-Transfer-Encoding: 8bit
|
|
|
0d097b |
|
|
|
0d097b |
In case `override` check was failed in _sss_ptr_hash_add()
|
|
|
0d097b |
`value` was leaking.
|
|
|
0d097b |
Fixed to do `override` check before value allocation.
|
|
|
0d097b |
|
|
|
0d097b |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
0d097b |
---
|
|
|
0d097b |
src/util/sss_ptr_hash.c | 14 +++++++-------
|
|
|
0d097b |
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
0d097b |
|
|
|
0d097b |
diff --git a/src/util/sss_ptr_hash.c b/src/util/sss_ptr_hash.c
|
|
|
0d097b |
index bf111a613..114b6edeb 100644
|
|
|
0d097b |
--- a/src/util/sss_ptr_hash.c
|
|
|
0d097b |
+++ b/src/util/sss_ptr_hash.c
|
|
|
0d097b |
@@ -217,21 +217,21 @@ errno_t _sss_ptr_hash_add(hash_table_t *table,
|
|
|
0d097b |
return ERR_INVALID_DATA_TYPE;
|
|
|
0d097b |
}
|
|
|
0d097b |
|
|
|
0d097b |
+ table_key.type = HASH_KEY_STRING;
|
|
|
0d097b |
+ table_key.str = discard_const_p(char, key);
|
|
|
0d097b |
+
|
|
|
0d097b |
+ if (override == false && hash_has_key(table, &table_key)) {
|
|
|
0d097b |
+ return EEXIST;
|
|
|
0d097b |
+ }
|
|
|
0d097b |
+
|
|
|
0d097b |
value = sss_ptr_hash_value_create(table, key, talloc_ptr);
|
|
|
0d097b |
if (value == NULL) {
|
|
|
0d097b |
return ENOMEM;
|
|
|
0d097b |
}
|
|
|
0d097b |
|
|
|
0d097b |
- table_key.type = HASH_KEY_STRING;
|
|
|
0d097b |
- table_key.str = discard_const_p(char, key);
|
|
|
0d097b |
-
|
|
|
0d097b |
table_value.type = HASH_VALUE_PTR;
|
|
|
0d097b |
table_value.ptr = value;
|
|
|
0d097b |
|
|
|
0d097b |
- if (override == false && hash_has_key(table, &table_key)) {
|
|
|
0d097b |
- return EEXIST;
|
|
|
0d097b |
- }
|
|
|
0d097b |
-
|
|
|
0d097b |
hret = hash_enter(table, &table_key, &table_value);
|
|
|
0d097b |
if (hret != HASH_SUCCESS) {
|
|
|
0d097b |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to add key %s!\n", key);
|
|
|
0d097b |
--
|
|
|
0d097b |
2.20.1
|
|
|
0d097b |
|