When attachments are deleted, delete_attachment() slides the entries
down in the idx array, but forgets to NULL out the last vacated slot.
If more attachments are added later on via OP_COMPOSE_EDIT_HEADERS and
the Attach: pseudo-header, mutt_gen_attach_list() will attempt to
re-use the ATTACHPTR in that last slot because it wasn't set to NULL.
This will be pointing to freed memory and likely segfault (at best).
FREE (&idx[x]);
for (; x < *idxlen - 1; x++)
idx[x] = idx[x+1];
+ idx[*idxlen - 1] = NULL;
menu->max = --(*idxlen);
return (0);