{
my_wcstombs (buf, buflen, state->wbuf, state->curpos);
i = strlen (buf);
- if (buf[i - 1] == '=' &&
+ if (i && buf[i - 1] == '=' &&
mutt_var_value_complete (buf, buflen, i))
tabs = 0;
else if (!mutt_command_complete (buf, buflen, i, tabs))
my_wcstombs (buf, buflen, state->wbuf, state->curpos);
/* see if the path has changed from the last time */
- if (tempbuf && templen == state->lastchar &&
- !memcmp (tempbuf, state->wbuf, state->lastchar * sizeof (wchar_t)))
+ if (!tempbuf || (templen == state->lastchar &&
+ !memcmp (tempbuf, state->wbuf, state->lastchar * sizeof (wchar_t))))
{
_mutt_select_file (buf, buflen, 0, multiple, files, numfiles);
set_option (OPTNEEDREDRAW);