[PATCH v3 4/4] perf tools: Use zfree() to be more safe in parse-events.c

From: Taeung Song
Date: Wed Feb 01 2017 - 07:34:45 EST


Signed-off-by: Taeung Song <treeze.taeung@xxxxxxxxx>
---
tools/perf/util/parse-events.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 316f054..ac47c12 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1479,7 +1479,7 @@ static void perf_pmu__parse_cleanup(void)

for (i = 0; i < perf_pmu_events_list_num; i++) {
p = perf_pmu_events_list + i;
- free(p->symbol);
+ zfree(&p->symbol);
}
zfree(&perf_pmu_events_list);
perf_pmu_events_list_num = 0;
@@ -1564,7 +1564,7 @@ perf_pmu__parse_check(const char *name)
r = bsearch(&p, perf_pmu_events_list,
(size_t) perf_pmu_events_list_num,
sizeof(struct perf_pmu_event_symbol), comp_pmu);
- free(p.symbol);
+ zfree(&p.symbol);
return r ? r->type : PMU_EVENT_SYMBOL_ERR;
}

@@ -1711,8 +1711,8 @@ static void parse_events_print_error(struct parse_events_error *err,
fprintf(stderr, "%*s\\___ %s\n", idx + 1, "", err->str);
if (err->help)
fprintf(stderr, "\n%s\n", err->help);
- free(err->str);
- free(err->help);
+ zfree(&err->str);
+ zfree(&err->help);
}

fprintf(stderr, "Run 'perf list' for a list of valid events\n");
@@ -2407,7 +2407,7 @@ void parse_events_terms__purge(struct list_head *terms)

list_for_each_entry_safe(term, h, terms, list) {
if (term->array.nr_ranges)
- free(term->array.ranges);
+ zfree(&term->array.ranges);
list_del_init(&term->list);
free(term);
}
@@ -2423,7 +2423,7 @@ void parse_events_terms__delete(struct list_head *terms)

void parse_events__clear_array(struct parse_events_array *a)
{
- free(a->ranges);
+ zfree(&a->ranges);
}

void parse_events_evlist_error(struct parse_events_evlist *data,
--
2.7.4