From 2e2d10eca6f07da02f3778afc9dd5bc3c8ff05e9 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 24 Mar 2020 15:37:28 +0100 Subject: [PATCH] x: check we still have an XIC context before accessing it (ce060a) --- x.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x.c b/x.c index a4c39bb..ac5787b 100644 --- a/x.c +++ b/x.c @@ -1009,6 +1009,7 @@ void ximdestroy(XIM xim, XPointer client, XPointer call) { xw.ime.xim = NULL; + xw.ime.xic = NULL; XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, ximinstantiate, NULL); } @@ -2050,13 +2051,15 @@ focus(XEvent *ev) return; if (ev->type == FocusIn) { - XSetICFocus(xw.ime.xic); + if (xw.ime.xic) + XSetICFocus(xw.ime.xic); win.mode |= MODE_FOCUSED; xseturgency(0); if (IS_SET(MODE_FOCUS)) ttywrite("\033[I", 3, 0); } else { - XUnsetICFocus(xw.ime.xic); + if (xw.ime.xic) + XUnsetICFocus(xw.ime.xic); win.mode &= ~MODE_FOCUSED; if (IS_SET(MODE_FOCUS)) ttywrite("\033[O", 3, 0);