[hackers] [st] fix possible rare crash when Xutf8TextPropertyToTextList fails || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Tue, 24 Aug 2021 13:47:51 +0200 (CEST)

commit 2f6e597ed871cff91c627850d03152cae5f45779
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Tue Aug 24 13:44:35 2021 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Tue Aug 24 13:44:35 2021 +0200

    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_AT_sdaoden.eu>, thanks!

diff --git a/x.c b/x.c
index 248d505..89786b8 100644
--- a/x.c
+++ b/x.c
_AT_@ -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);
_AT_@ -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);
Received on Tue Aug 24 2021 - 13:47:51 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 24 2021 - 13:48:37 CEST