perf env: 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: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2023-04-12 09:50:08 -03:00
parent 313b4c1ccd
commit 9fbde6c800

View File

@ -149,7 +149,7 @@ static void perf_env__purge_bpf(struct perf_env *env)
node = rb_entry(next, struct bpf_prog_info_node, rb_node); node = rb_entry(next, struct bpf_prog_info_node, rb_node);
next = rb_next(&node->rb_node); next = rb_next(&node->rb_node);
rb_erase(&node->rb_node, root); rb_erase(&node->rb_node, root);
free(node->info_linear); zfree(&node->info_linear);
free(node); free(node);
} }