aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-08-04 00:42:58 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-08-04 00:42:58 +0530
commitccfccb7187a82ebe7fce3ca2bbc3eaa94a1b4ccd (patch)
tree36b6184cebfd00d564da4bc0b0baab8b7276844c /src
parent8d94809897df2528c63ef99aa54b4a630ddcb789 (diff)
downloadnnn-ccfccb7187a82ebe7fce3ca2bbc3eaa94a1b4ccd.tar.gz
Detect odd hex symbols in NNN_COLORS
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nnn.c b/src/nnn.c
index e63d706..1349f36 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -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;