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
This commit is contained in:
bakkeby 2022-02-24 13:25:36 +01:00
parent 9ab02993c3
commit 1a7cc16bec

4
st.c
View File

@ -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)