fix possible rare crash when Xutf8TextPropertyToTextList fails

from the XmbTextListToTextProperty(3) man page:

"If insufficient memory is available for the new value string, the functions
return XNoMemory.  If the current locale is not supported, the functions return
XLocaleNotSupported.  In both of these error cases, the functions do not set
text_prop_return."

Reported by Steffen Nurpmeso <steffen@sdaoden.eu>, thanks!
This commit is contained in:
Hiltjo Posthuma 2021-08-24 13:44:35 +02:00
parent 1d3142da96
commit 2f6e597ed8

10
x.c
View File

@ -1588,8 +1588,9 @@ xseticontitle(char *p)
XTextProperty prop; XTextProperty prop;
DEFAULT(p, opt_title); DEFAULT(p, opt_title);
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop); &prop) != Success)
return;
XSetWMIconName(xw.dpy, xw.win, &prop); XSetWMIconName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname); XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
XFree(prop.value); XFree(prop.value);
@ -1601,8 +1602,9 @@ xsettitle(char *p)
XTextProperty prop; XTextProperty prop;
DEFAULT(p, opt_title); DEFAULT(p, opt_title);
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop); &prop) != Success)
return;
XSetWMName(xw.dpy, xw.win, &prop); XSetWMName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname); XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
XFree(prop.value); XFree(prop.value);