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\\'
This commit is contained in:
parent
eb3b894f40
commit
a6bbc0c96b
4
x.c
4
x.c
|
@ -818,7 +818,7 @@ xloadcols(void)
|
||||||
int
|
int
|
||||||
xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
|
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;
|
return 1;
|
||||||
|
|
||||||
*r = dc.col[x].color.red >> 8;
|
*r = dc.col[x].color.red >> 8;
|
||||||
|
@ -833,7 +833,7 @@ xsetcolorname(int x, const char *name)
|
||||||
{
|
{
|
||||||
Color ncolor;
|
Color ncolor;
|
||||||
|
|
||||||
if (!BETWEEN(x, 0, dc.collen))
|
if (!BETWEEN(x, 0, dc.collen - 1))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!xloadcolor(x, name, &ncolor))
|
if (!xloadcolor(x, name, &ncolor))
|
||||||
|
|
Loading…
Reference in New Issue