perf stat: Fix memory leak on error path
Ian Rogers
reviewerPATCH 1/1 perf stat: Fix memory leak on error path
Strdup is used to deduplicate, ensure it isn't overwriting an already created string by freeing first.
Signed-off-by Ian Rogers <[email protected]>
--- tools/perf/util/stat-shadow.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/stat-shadow.c +1 -0
@@ -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;
Signature · 1 line
2.34.0.rc0.344.g81b53c2807-goog
Arnaldo Carvalho de Melo
maintainerEm Sun, Nov 07, 2021 at 01:54:44AM -0700, Ian Rogers escreveu:
Quoted 1 line
Strdup is used to deduplicate, ensure it isn't overwriting an already
s/overwriting/leaking/g
Right?
- Arnaldo
Quoted 21 lines
created string by freeing first.
Signed-off-by Ian Rogers <[email protected]>--- tools/perf/util/stat-shadow.c | 1 + 1 file changed, 1 insertion(+)tools/perf/util/stat-shadow.c +1
-0@@ -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;Signature · 1 line
2.34.0.rc0.344.g81b53c2807-goog
Signature · 1 line
- Arnaldo