aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-08-24 13:44:35 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-08-24 13:44:35 +0200
commit2f6e597ed871cff91c627850d03152cae5f45779 (patch)
treeed4a5c5cbeac9828b79d111e19484d89d1fa9f55
parent1d3142da968da7f6f61f1c1708f39ca233eda150 (diff)
downloadst-patched-2f6e597ed871cff91c627850d03152cae5f45779.tar.bz2
st-patched-2f6e597ed871cff91c627850d03152cae5f45779.tar.xz
st-patched-2f6e597ed871cff91c627850d03152cae5f45779.zip
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!
-rw-r--r--x.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/x.c b/x.c
index 248d505..89786b8 100644
--- a/x.c
+++ b/x.c
@@ -1588,8 +1588,9 @@ xseticontitle(char *p)
1588 XTextProperty prop; 1588 XTextProperty prop;
1589 DEFAULT(p, opt_title); 1589 DEFAULT(p, opt_title);
1590 1590
1591 Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, 1591 if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
1592 &prop); 1592 &prop) != Success)
1593 return;
1593 XSetWMIconName(xw.dpy, xw.win, &prop); 1594 XSetWMIconName(xw.dpy, xw.win, &prop);
1594 XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname); 1595 XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
1595 XFree(prop.value); 1596 XFree(prop.value);
@@ -1601,8 +1602,9 @@ xsettitle(char *p)
1601 XTextProperty prop; 1602 XTextProperty prop;
1602 DEFAULT(p, opt_title); 1603 DEFAULT(p, opt_title);
1603 1604
1604 Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, 1605 if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
1605 &prop); 1606 &prop) != Success)
1607 return;
1606 XSetWMName(xw.dpy, xw.win, &prop); 1608 XSetWMName(xw.dpy, xw.win, &prop);
1607 XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname); 1609 XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
1608 XFree(prop.value); 1610 XFree(prop.value);