From 389c17c5c6656027fcece6ddd4322e4e64f17ff6 Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Mon, 22 Oct 2018 13:57:11 +0200 Subject: [PATCH] Fix ressource leak in client/config.c get_config_entry The leak happens due to using strndup to create a temporary string without freeing it afterwards. See: https://pagure.io/freeipa/issue/7738 Signed-off-by: Thomas Woerner Reviewed-By: Christian Heimes --- client/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/config.c b/client/config.c index ecc126ff4..a09564b70 100644 --- a/client/config.c +++ b/client/config.c @@ -123,17 +123,18 @@ get_config_entry(char * in_data, const char *section, const char *key) line++; p = strchr(line, ']'); if (p) { - tmp = strndup(line, p - line); if (in_section) { /* We exited the matching section without a match */ free(data); return NULL; } + tmp = strndup(line, p - line); if (strcmp(section, tmp) == 0) { free(tmp); in_section = 1; continue; } + free(tmp); } } /* [ */