[PATCH v1 2/5] perf help: Ensure clean_cmds is called on all paths

From: Ian Rogers
Date: Sun Jun 11 2023 - 19:36:45 EST


Avoid potential memory leaks.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/help-unknown-cmd.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index ab9e16123626..eab99ea6ac01 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -92,6 +92,7 @@ const char *help_unknown_cmd(const char *cmd)

main_cmds.names[0] = NULL;
clean_cmdnames(&main_cmds);
+ clean_cmdnames(&other_cmds);
fprintf(stderr, "WARNING: You called a perf program named '%s', "
"which does not exist.\n"
"Continuing under the assumption that you meant '%s'\n",
@@ -114,5 +115,7 @@ const char *help_unknown_cmd(const char *cmd)
fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
}
end:
+ clean_cmdnames(&main_cmds);
+ clean_cmdnames(&other_cmds);
exit(1);
}
--
2.41.0.162.gfafddb0af9-goog