libsubcmd: Fix memory leak in uniq()
authorIan Rogers <irogers@google.com>
Fri, 8 Dec 2023 00:05:13 +0000 (16:05 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jan 2024 21:29:17 +0000 (18:29 -0300)
commitad30469a841b50dbb541df4d6971d891f703c297
treea5bb47acc0ccbdcc8ef3ddd5fa898b63e277bcf7
parent6af6d22495efeb00cb4e220a4e6e30b5be3afdf3
libsubcmd: Fix memory leak in uniq()

uniq() will write one command name over another causing the overwritten
string to be leaked. Fix by doing a pass that removes duplicates and a
second that removes the holes.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Chenyuan Mi <cymi20@fudan.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231208000515.1693746-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/subcmd/help.c