Skip to content

Commit 59eb9f5

Browse files
SiegeLordExSiegeLord
authored andcommitted
Fix crash when using the LC_CTYPE=eo.ut8 on X11.
The window title setting implementation wasn't checking an error return. It now does so, logging the error if it fails. In this case, it fails for this locale. I have not investigated whether this can be made to work, but at least it doesn't segfault/hang etc. Fixes #1651
1 parent c870f46 commit 59eb9f5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/x/xdisplay.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,21 @@ static void xdpy_set_window_title_default(ALLEGRO_DISPLAY *display, const char *
12161216
Atom _NET_WM_NAME = XInternAtom(system->x11display, "_NET_WM_NAME", False);
12171217
char *list[1] = { (char *) title };
12181218
XTextProperty property;
1219-
1220-
Xutf8TextListToTextProperty(system->x11display, list, 1, XUTF8StringStyle,
1219+
int status = Xutf8TextListToTextProperty(system->x11display, list, 1, XUTF8StringStyle,
12211220
&property);
1222-
XSetTextProperty(system->x11display, glx->window, &property, WM_NAME);
1223-
XSetTextProperty(system->x11display, glx->window, &property, _NET_WM_NAME);
1224-
XSetTextProperty(system->x11display, glx->window, &property, XA_WM_NAME);
1225-
XFree(property.value);
1221+
1222+
if (status == Success) {
1223+
XSetTextProperty(system->x11display, glx->window, &property, WM_NAME);
1224+
XSetTextProperty(system->x11display, glx->window, &property, _NET_WM_NAME);
1225+
XSetTextProperty(system->x11display, glx->window, &property, XA_WM_NAME);
1226+
XFree(property.value);
1227+
}
1228+
else if (status == XLocaleNotSupported) {
1229+
ALLEGRO_WARN("Couldn't set window title. Xutf8TextListToTextProperty returned XLocaleNotSupported.\n");
1230+
}
1231+
else {
1232+
ALLEGRO_WARN("Couldn't set window title. Xutf8TextListToTextProperty returned: %d\n", status);
1233+
}
12261234
}
12271235
{
12281236
XClassHint *hint = XAllocClassHint();

0 commit comments

Comments
 (0)