Commit: 700681675c37d417eeeeabe93758f40d579556e3
Parent: 1daeffd2f5964058f22c3d08f0e2dcad1568e87a
Author: Hiltjo Posthuma
Date: Tue, 12 Feb 2019 19:10:43 +0100
fix crash when XOpenIM returns NULL
for example when IME variables are set, but the program is not started (yet).
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c
@@ -354,8 +354,16 @@ setup(void)
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
XSetClassHint(dpy, win, &ch);
- /* Open input methods */
- xim = XOpenIM(dpy, NULL, NULL, NULL);
+ /* input methods */
+ if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
+ XSetLocaleModifiers("@im=local");
+ if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
+ XSetLocaleModifiers("@im=");
+ if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
+ die("XOpenIM failed. Could not open input device.\n");
+ }
+ }
+
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL);
XMapRaised(dpy, win);