perf parse-events: Use zfree() to reduce chances of use after free

Do defensive programming by using zfree() to initialize freed pointers
to NULL, so that eventual use after free result in a NULL pointer deref
instead of more subtle behaviour.

Also remove one NULL test before free(), as it accepts a NULL arg and we
get one line shaved not doing it explicitely.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a77f8184
...@@ -2020,7 +2020,7 @@ int perf_pmu__test_parse_init(void) ...@@ -2020,7 +2020,7 @@ int perf_pmu__test_parse_init(void)
err_free: err_free:
for (j = 0, tmp = list; j < i; j++, tmp++) for (j = 0, tmp = list; j < i; j++, tmp++)
free(tmp->symbol); zfree(&tmp->symbol);
free(list); free(list);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment