From 886ff516cf98ade239677ba3a3e3591fa341ce9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20L=C3=B3pez?= <allopez@redhat.com>
Date: Wed, 6 Apr 2022 11:58:48 +0200
Subject: [PATCH] sssctl: free one malloc-allocated variable.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

One variable is allocated by popt using malloc and has to be freed.
As it is a const char *, we need to bypass the const modifier.

Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
---
 src/tools/sssctl/sssctl_logs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c
index bd758f272..c375700b4 100644
--- a/src/tools/sssctl/sssctl_logs.c
+++ b/src/tools/sssctl/sssctl_logs.c
@@ -356,9 +356,6 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline,
 
     CHECK_ROOT(ret, debug_prg_name);
 
-    /* free pc_config_file? */
-    /* free debug_as_string? */
-
     debug_to_set = parse_debug_level(debug_as_string);
     CHECK(debug_to_set == SSSDBG_INVALID, fini, "Invalid debug level.");
 
@@ -387,6 +384,10 @@ errno_t sssctl_debug_level(struct sss_cmdline *cmdline,
 
 fini:
     talloc_free(ctx);
+    /* pc_config_file is allocated by popt using malloc().
+     * debug_as_string is not allocated but points to the command line. */
+    free(discard_const(pc_config_file));
+
     return ret;
 }
 
-- 
2.32.0.windows.1

