fix crash when XOpenIM returns NULL f5036b90
for example when IME variables are set, but the program is not started (yet).
Hiltjo Posthuma · 2019-02-12 19:10 1 file(s) · +11 −2
dmenu.c +11 −2
664 664
	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
665 665
	XSetClassHint(dpy, win, &ch);
666 666
667 -
	/* open input methods */
668 -
	xim = XOpenIM(dpy, NULL, NULL, NULL);
667 +
668 +
	/* input methods */
669 +
	if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
670 +
		XSetLocaleModifiers("@im=local");
671 +
		if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
672 +
			XSetLocaleModifiers("@im=");
673 +
			if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
674 +
				die("XOpenIM failed. Could not open input device.\n");
675 +
		}
676 +
	}
677 +
669 678
	xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
670 679
	                XNClientWindow, win, XNFocusWindow, win, NULL);
671 680