From e5ea493d3299caad340ecbd6ef7a6fd563224f43 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 10 Aug 2020 11:36:10 +0200 Subject: [PATCH] systray: systray window may always not exist depending on configuration and number of monitors available, causing segfault in cleanup. Fixing double free on freeing fonts. --- dwm.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/dwm.c b/dwm.c index 296490f..f9d923f 100644 --- a/dwm.c +++ b/dwm.c @@ -962,7 +962,6 @@ cleanup(void) Layout foo = { "", NULL }; Monitor *m; size_t i; - view(&a); selmon->lt[selmon->sellt] = &foo; for (m = mons; m; m = m->next) @@ -972,9 +971,11 @@ cleanup(void) while (mons) cleanupmon(mons); #if BAR_SYSTRAY_PATCH - if (showsystray) { - XUnmapWindow(dpy, systray->win); - XDestroyWindow(dpy, systray->win); + if (showsystray && systray) { + if (systray->win) { + XUnmapWindow(dpy, systray->win); + XDestroyWindow(dpy, systray->win); + } free(systray); } #endif // BAR_SYSTRAY_PATCH @@ -988,11 +989,6 @@ cleanup(void) free(scheme[i]); free(scheme); XDestroyWindow(dpy, wmcheckwin); - #if BAR_PANGO_PATCH - drw_font_free(drw->font); - #else - drw_fontset_free(drw->fonts); - #endif // BAR_PANGO_PATCH drw_free(drw); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);