Skip to content

Commit 365126f

Browse files
committed
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! Reference: https://git.suckless.org/st/commit/2f6e597ed871cff91c627850d03152cae5f45779.html
1 parent f510808 commit 365126f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

x.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,9 @@ xseticontitle(char *p)
16071607
XTextProperty prop;
16081608
DEFAULT(p, opt_title);
16091609

1610-
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
1610+
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
1611+
&prop) != Success)
1612+
return;
16111613
XSetWMIconName(xw.dpy, xw.win, &prop);
16121614
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
16131615
XFree(prop.value);
@@ -1619,7 +1621,9 @@ xsettitle(char *p)
16191621
XTextProperty prop;
16201622
DEFAULT(p, opt_title);
16211623

1622-
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
1624+
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
1625+
&prop) != Success)
1626+
return;
16231627
XSetWMName(xw.dpy, xw.win, &prop);
16241628
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
16251629
XFree(prop.value);

0 commit comments

Comments
 (0)