]> granicus.if.org Git - neomutt/commitdiff
range check - parse_set
authorRichard Russon <rich@flatcap.org>
Mon, 19 Mar 2018 19:30:05 +0000 (19:30 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 20 Mar 2018 01:01:45 +0000 (01:01 +0000)
init.c

diff --git a/init.c b/init.c
index 38ceeb8353852081157cd7948759e3d33e59e59a..4e74fac9b4231189be7dba92a1c8fb7a845fc78b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2535,7 +2535,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
         }
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_MAGIC)
+    else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_MAGIC))
     {
       if (query || *s->dptr != '=')
       {
@@ -2573,7 +2573,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
         break;
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_NUMBER)
+    else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_NUMBER))
     {
       short *ptr = (short *) MuttVars[idx].var;
       short val;
@@ -2637,7 +2637,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
       }
 #endif
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_QUAD)
+    else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_QUAD))
     {
       if (query)
       {
@@ -2679,7 +2679,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
           *(unsigned char *) MuttVars[idx].var = MUTT_YES;
       }
     }
-    else if (DTYPE(MuttVars[idx].type) == DT_SORT)
+    else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_SORT))
     {
       const struct Mapping *map = NULL;
 
@@ -2733,7 +2733,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
       }
     }
 #ifdef USE_HCACHE
-    else if (DTYPE(MuttVars[idx].type) == DT_HCACHE)
+    else if ((idx >= 0) && (DTYPE(MuttVars[idx].type) == DT_HCACHE))
     {
       if (query || (*s->dptr != '='))
       {