Detect odd hex symbols in NNN_COLORS

This commit is contained in:
Arun Prakash Jana 2020-08-04 00:42:58 +05:30
parent 8d94809897
commit ccfccb7187
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -1589,7 +1589,6 @@ static bool initcurses(void *oldmask)
if (colors || !getenv("NO_COLOR")) {
uint *pcode;
char ch;
bool ext = FALSE;
start_color();
@ -1622,16 +1621,17 @@ static bool initcurses(void *oldmask)
if (colors && *colors) {
if (ext) {
ch = *colors;
if (*++colors) {
*pcode = (16 * xchartohex(ch)) + xchartohex(*colors);
++colors;
} else
*pcode = xchartohex(ch);
} else {
*pcode = xchartohex(*colors) << 4;
if (*++colors)
*pcode += xchartohex(*colors);
else { /* Each color code must be 2 hex symbols */
exitcurses();
fprintf(stderr, "NNN_COLORS!\n");
return FALSE;
}
} else
*pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
++colors;
}
++colors;
} else
*pcode = 4;