commit 1a7cc16bec22c159cf1c0939c60a72c66de77c5b
parent 9ab02993c3906049965c10319fc6baf403ef4456
Author: bakkeby <bakkeby@gmail.com>
Date: Thu, 24 Feb 2022 13:25:36 +0100
Fix null pointer access in strhandle
According to the spec the argument is optional for 104, so p can be
NULL as can be tested with printf '\x1b]104\x07'. This is a regression
of 8e31030.
Ref.
- https://git.suckless.org/st/commit/a0467c802d4f86ed162486e3453dd61181423902.html
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/st.c b/st.c
@@ -2525,7 +2525,7 @@ strhandle(void)
break;
p = strescseq.args[((par == 4) ? 2 : 1)];
/* FALLTHROUGH */
- case 104: /* color reset, here p = NULL */
+ case 104: /* color reset */
if (par == 10)
j = defaultfg;
else if (par == 11)
@@ -2535,7 +2535,7 @@ strhandle(void)
else
j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
- if (!strcmp(p, "?"))
+ if (p && !strcmp(p, "?"))
osc4_color_response(j);
else if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1)