[PATCH] perf_counter tools: Fix memory leaks of add_cmdname()

From: Sohaib Mohamed
Date: Fri Nov 19 2021 - 03:47:06 EST


ASan reports some memory leaks when running:

$ perf xyz

This patch adds the missing clean_cmdnames()

Fixes: 078006012401 ("perf_counter tools: add in basic glue from Git")

Signed-off-by: Sohaib Mohamed <sohaib.amhmd@xxxxxxxxx>
---
tools/lib/subcmd/help.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
index bf02d62a3b2b..4a433f4d19a1 100644
--- a/tools/lib/subcmd/help.c
+++ b/tools/lib/subcmd/help.c
@@ -187,6 +187,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,

add_cmdname(cmds, de->d_name + prefix_len, entlen);
}
+ clean_cmdnames(cmds);
closedir(dir);
free(buf);
}
--
2.25.1