The refactor in
2b9c40f13e13 exposed a bug I hadn't noticed. The
match loop performed a FREE() on the slot. Then, below, it was
checking if (*envp) to see whether it was overwriting or creating a
new slot. However, FREE() nulls out *envp. This would end up
truncating the envlist just after the set slot!
Move the free down, using a mutt_str_replace(), when overwriting the
slot.
while (envp && *envp)
{
if (!mutt_strncmp (name, *envp, len) && (*envp)[len] == '=')
- {
- FREE (envp); /* __FREE_CHECKED__ */
break;
- }
envp++;
count++;
}
/* If slot found, overwrite */
if (envp && *envp)
- *envp = safe_strdup (work);
+ mutt_str_replace (envp, work);
/* If not found, add new slot */
else