]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix illegal access
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 2 Aug 2020 11:33:35 +0000 (17:03 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 2 Aug 2020 11:33:35 +0000 (17:03 +0530)
src/nnn.c

index 714ea353a1c445c44db059ccad0ac5d50c362426..baeef064de67272f03054c5e1c21383b0c84a139 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1594,6 +1594,8 @@ static bool initcurses(void *oldmask)
                use_default_colors();
 
                if (colors && *colors == '#') {
+                       char *sep = strchr(colors, ';');
+
                        if (COLORS >= 256) {
                                ++colors;
                                ext = TRUE;
@@ -1603,12 +1605,13 @@ static bool initcurses(void *oldmask)
                                 * to NULL so we don't interpret separator and fallback
                                 * if fewer than CTX_MAX xterm 256 colors are specified.
                                 */
-                               char *sep = strchr(colors, ';');
                                if (sep)
                                        *sep = '\0';
-                       } else
-                               /* Check if 8 colors fallback is appended */
-                               colors = strchr(colors, ';') + 1;
+                       } else {
+                               colors = sep; /* Detect if 8 colors fallback is appended */
+                               if (colors)
+                                       ++colors;
+                       }
                }
 
                /* Get and set the context colors */