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.
This commit is contained in:
Jochen Sprickerhof 2021-12-27 11:41:42 +01:00 committed by Hiltjo Posthuma
parent 273db5ceaf
commit a0467c802d
1 changed files with 2 additions and 2 deletions

4
st.c
View File

@ -1960,10 +1960,10 @@ strhandle(void)
break; break;
p = strescseq.args[2]; p = strescseq.args[2];
/* FALLTHROUGH */ /* FALLTHROUGH */
case 104: /* color reset, here p = NULL */ case 104: /* color reset */
j = (narg > 1) ? atoi(strescseq.args[1]) : -1; j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
if (!strcmp(p, "?")) if (p && !strcmp(p, "?"))
osc4_color_response(j); osc4_color_response(j);
else if (xsetcolorname(j, p)) { else if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1) if (par == 104 && narg <= 1)