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: mutt-1-8-1-rel~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ac64f6eada9a538813670c4812f72973ebb3cba;p=mutt Fix mutt_envlist_set() for the case that envlist is null. (see #3922) --- diff --git a/init.c b/init.c index 7e027c66..953e5c8b 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; } }