st: Fix invalid free() in xsettitle()

by checking return value of `Xutf8TextListToTextProperty()`.
This commit is contained in:
Tee KOBAYASHI 2022-04-25 08:19:29 +09:00 committed by xtkoba
parent 4f8c07980d
commit aee88ebe56
2 changed files with 21 additions and 2 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="A simple virtual terminal emulator for X"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="Tristan Ross <spaceboyross@yandex.com>"
TERMUX_PKG_VERSION=0.8.4
TERMUX_PKG_REVISION=5
TERMUX_PKG_REVISION=6
TERMUX_PKG_SRCURL="http://dl.suckless.org/st/st-$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=d42d3ceceb4d6a65e32e90a5336e3d446db612c3fbd9ebc1780bc6c9a03346a6
# FIXME: config.h specified a Liberation Mono font which is not available in Termux.
@ -14,5 +14,6 @@ TERMUX_PKG_EXTRA_MAKE_ARGS="TERMINFO=$TERMUX_PREFIX/share/terminfo"
TERMUX_PKG_RM_AFTER_INSTALL="share/terminfo"
termux_step_configure() {
cp "$TERMUX_PKG_BUILDER_DIR/config.h" "config.h"
sed "s:@TERMUX_PREFIX@:${TERMUX_PREFIX}:g" \
"$TERMUX_PKG_BUILDER_DIR/config.h" > config.h
}

View File

@ -0,0 +1,18 @@
--- a/x.c
+++ b/x.c
@@ -1585,11 +1585,14 @@
void
xsettitle(char *p)
{
+ int r;
XTextProperty prop;
DEFAULT(p, opt_title);
- Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+ r = Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop);
+ if (r != Success)
+ return;
XSetWMName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
XFree(prop.value);