From 239b223fff46a346a17f01dfc0b843f7b2e7ff19 Mon Sep 17 00:00:00 2001 From: artygus Date: Wed, 4 Mar 2015 21:18:04 +0300 Subject: [PATCH] x11 driver: handle errors caused by missing locales --- caca/driver/x11.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/caca/driver/x11.c b/caca/driver/x11.c index 6bd04cf..aa02bbf 100644 --- a/caca/driver/x11.c +++ b/caca/driver/x11.c @@ -333,12 +333,23 @@ static int x11_init_graphics(caca_display_t *dp) #if defined X_HAVE_UTF8_STRING list = XVaCreateNestedList(0, XNFontSet, dp->drv.p->font_set, NULL); dp->drv.p->im = XOpenIM(dp->drv.p->dpy, NULL, NULL, NULL); + + if (dp->drv.p->im == NULL) { + fprintf(stderr, "x11 driver error: unable to open input method\n"); + return -1; + } + dp->drv.p->ic = XCreateIC(dp->drv.p->im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, dp->drv.p->window, XNPreeditAttributes, list, XNStatusAttributes, list, NULL); + + if (dp->drv.p->ic == NULL) { + fprintf(stderr, "x11 driver error: unable to create input context\n"); + return -1; + } #endif return 0;