perf evlist: 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.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c77ceb2e
...@@ -2325,7 +2325,7 @@ int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *o ...@@ -2325,7 +2325,7 @@ int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *o
close_timerfd: close_timerfd:
close(eet->timerfd); close(eet->timerfd);
free_eet_times: free_eet_times:
free(eet->times); zfree(&eet->times);
free_eet: free_eet:
free(eet); free(eet);
return err; return err;
...@@ -2407,7 +2407,7 @@ void event_enable_timer__exit(struct event_enable_timer **ep) ...@@ -2407,7 +2407,7 @@ void event_enable_timer__exit(struct event_enable_timer **ep)
{ {
if (!ep || !*ep) if (!ep || !*ep)
return; return;
free((*ep)->times); zfree(&(*ep)->times);
zfree(ep); zfree(ep);
} }
......
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