st-flexipatch

My st-flexipatch configuration
git clone git://git.ethandl.dev/st-flexipatch
Log | Files | Refs | README | LICENSE

commit 859906235eb65a9b78d326806adb1e061d0693bc
parent 4a1d981d54cead40a4bc20922dc6f9d3dea1ebb5
Author: Bakkeby <bakkeby@gmail.com>
Date:   Sun,  8 Oct 2023 20:18:30 +0200

Fix bounds checks of dc.col

dc.collen is the length of dc.col, not the maximum index, hence if x is
equal to dc.collen, then it's an error.

With config.def.h, the last valid index is 259, so this correctly
reports "black":

    $ printf '\033]4;259;?\e\\'

260 is an invalid index and this reports garbage instead of printing an
error:

    $ printf '\033]4;260;?\e\\'

ref.
https://git.suckless.org/st/commit/a6bbc0c96b0a1db804061b0db79101c6b26aec57.html

Diffstat:
Mx.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/x.c b/x.c @@ -1002,7 +1002,7 @@ xloadcols(void) int xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b) { - if (!BETWEEN(x, 0, dc.collen)) + if (!BETWEEN(x, 0, dc.collen - 1)) return 1; *r = dc.col[x].color.red >> 8; @@ -1017,7 +1017,7 @@ xsetcolorname(int x, const char *name) { Color ncolor; - if (!BETWEEN(x, 0, dc.collen)) + if (!BETWEEN(x, 0, dc.collen - 1)) return 1; if (!xloadcolor(x, name, &ncolor))