perf expr: Use zfree() to reduce chances of use after free
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Apr 2023 12:50:08 +0000 (09:50 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Apr 2023 13:06:11 +0000 (10:06 -0300)
commita77f8184a07cbe81cdee30582640ed1b412705fc
treeaebb8b9c10d4d65894661b16eb7d21b4e3c02e27
parentcdf13c0918c9b1b233d6db690fc4c06afbc29e57
perf expr: 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: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/expr.c