From 1a7cc16bec22c159cf1c0939c60a72c66de77c5b Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 24 Feb 2022 13:25:36 +0100 Subject: [PATCH] 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 --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 5d6f0e2..2df5c47 100644 --- 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)