]> Sergey Matveev's repositories - st.git/commitdiff
Fix null pointer access in strhandle
authorJochen Sprickerhof <git@jochen.sprickerhof.de>
Mon, 27 Dec 2021 10:41:42 +0000 (11:41 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 27 Dec 2021 12:07:11 +0000 (13:07 +0100)
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.

st.c

diff --git a/st.c b/st.c
index 6783c2b46cc51495e4e02e9079fefd41e7223155..de2dd0ec88c489ac332b223fdef10923198c62d0 100644 (file)
--- a/st.c
+++ b/st.c
@@ -1960,10 +1960,10 @@ strhandle(void)
                                break;
                        p = strescseq.args[2];
                        /* FALLTHROUGH */
-               case 104: /* color reset, here p = NULL */
+               case 104: /* color reset */
                        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)