From: Kevin McCarthy Date: Sat, 18 Mar 2017 21:39:12 +0000 (-0700) Subject: Fix mutt_envlist_set() for the case that envlist is null. (see #3922) X-Git-Tag: neomutt-20170414^2~25^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2df2921fd3164b4541dcc8e5d6006edde5b4bf17;p=neomutt Fix mutt_envlist_set() for the case that envlist is null. (see #3922) --- diff --git a/init.c b/init.c index 7e027c66e..953e5c8bf 100644 --- 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; } }