]> Sergey Matveev's repositories - st.git/commitdiff
fix possible rare crash when Xutf8TextPropertyToTextList fails
authorHiltjo Posthuma <hiltjo@codemadness.org>
Tue, 24 Aug 2021 11:44:35 +0000 (13:44 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Tue, 24 Aug 2021 11:44:35 +0000 (13:44 +0200)
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!

x.c

diff --git a/x.c b/x.c
index 248d5050111d0b3bae2785e90480502807139197..89786b8bd7a5db38ab008c2d7287b49e86e01d60 100644 (file)
--- a/x.c
+++ b/x.c
@@ -1588,8 +1588,9 @@ xseticontitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
-       Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
-                       &prop);
+       if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+                                       &prop) != Success)
+               return;
        XSetWMIconName(xw.dpy, xw.win, &prop);
        XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
        XFree(prop.value);
@@ -1601,8 +1602,9 @@ xsettitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
-       Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
-                       &prop);
+       if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+                                       &prop) != Success)
+               return;
        XSetWMName(xw.dpy, xw.win, &prop);
        XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
        XFree(prop.value);