From ed4202b52f3651f9635072b055fffc2f7b51fa4d Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 17 Feb 2019 16:59:00 +0000 Subject: [PATCH] Fix memory leaks Restrict the use of ps_g to xerror() and main(). Signed-off-by: Yuxuan Shui --- src/compton.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compton.c b/src/compton.c index 831ccc96..c6f169c1 100644 --- a/src/compton.c +++ b/src/compton.c @@ -2391,7 +2391,6 @@ session_init(int argc, char **argv, Display *dpy, const char *config_file, ps->loop = EV_DEFAULT; pixman_region32_init(&ps->screen_reg); - ps_g = ps; ps->ignore_tail = &ps->ignore_head; gettimeofday(&ps->time_start, NULL); @@ -2555,6 +2554,7 @@ session_init(int argc, char **argv, Display *dpy, const char *config_file, NULL); if (r) { ps->present_exists = true; + free(r); } } @@ -2910,9 +2910,6 @@ session_destroy(session_t *ps) { ev_signal_stop(ps->loop, &ps->usr1_signal); ev_signal_stop(ps->loop, &ps->int_signal); - if (ps == ps_g) - ps_g = NULL; - log_deinit_tls(); } @@ -3019,6 +3016,7 @@ main(int argc, char **argv) { quit = ps_g->quit; session_destroy(ps_g); free(ps_g); + ps_g = NULL; } while (!quit); if (dpy) {