]> granicus.if.org Git - neomutt/commitdiff
Fix mutt_envlist_set() for the case that envlist is null. (see #3922)
authorKevin McCarthy <kevin@8t8.us>
Sat, 18 Mar 2017 21:39:12 +0000 (14:39 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sat, 18 Mar 2017 21:39:12 +0000 (14:39 -0700)
init.c

diff --git a/init.c b/init.c
index 7e027c66e2f372431ea5a558d55ea03dfc4a8dad..953e5c8bf3377c671bfcceb919c5cf17ee54b149 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1879,16 +1879,15 @@ void mutt_envlist_set (const char *name, const char *value)
   snprintf (work, sizeof(work), "%s=%s", NONULL (name), NONULL (value));
 
   /* If slot found, overwrite */
-  if (*envp)
+  if (envp && *envp)
     *envp = safe_strdup (work);
 
   /* If not found, add new slot */
   else
   {
-    *envp = safe_strdup (work);
-    count++;
-    safe_realloc (&envlist, sizeof(char *) * (count + 1));
-    envlist[count] = NULL;
+    safe_realloc (&envlist, sizeof(char *) * (count + 2));
+    envlist[count] = safe_strdup (work);
+    envlist[count + 1] = NULL;
   }
 }