perf daemon: 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 79b40a1b
......@@ -193,7 +193,7 @@ static int session_config(struct daemon *daemon, const char *var, const char *va
if (!same) {
if (session->run) {
free(session->run);
zfree(&session->run);
pr_debug("reconfig: session %s is changed\n", name);
}
......@@ -924,9 +924,9 @@ static void daemon__signal(struct daemon *daemon, int sig)
static void daemon_session__delete(struct daemon_session *session)
{
free(session->base);
free(session->name);
free(session->run);
zfree(&session->base);
zfree(&session->name);
zfree(&session->run);
free(session);
}
......@@ -975,9 +975,9 @@ static void daemon__exit(struct daemon *daemon)
list_for_each_entry_safe(session, h, &daemon->sessions, list)
daemon_session__remove(session);
free(daemon->config_real);
free(daemon->config_base);
free(daemon->base);
zfree(&daemon->config_real);
zfree(&daemon->config_base);
zfree(&daemon->base);
}
static int daemon__reconfig(struct daemon *daemon)
......
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