Re: [PATCH] perf stat: Fix memory leak on error path
From: Arnaldo Carvalho de Melo
Date: Sun Nov 07 2021 - 10:33:13 EST
Em Sun, Nov 07, 2021 at 01:54:44AM -0700, Ian Rogers escreveu:
> Strdup is used to deduplicate, ensure it isn't overwriting an already
s/overwriting/leaking/g
Right?
- Arnaldo
> created string by freeing first.
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/stat-shadow.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> index 69f3cf3b4a44..e4fb02b05130 100644
> --- a/tools/perf/util/stat-shadow.c
> +++ b/tools/perf/util/stat-shadow.c
> @@ -444,6 +444,7 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list)
> "Add %s event to groups to get metric expression for %s\n",
> metric_name,
> counter->name);
> + free(printed);
> printed = strdup(metric_name);
> }
> invalid = true;
> --
> 2.34.0.rc0.344.g81b53c2807-goog
--
- Arnaldo