From: Kevin McCarthy Date: Tue, 5 Jan 2016 00:28:56 +0000 (-0800) Subject: Add a couple missing ATTACHPTR->tree frees. X-Git-Tag: neomutt-20160404~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eeb8d3b8e0ece3bf9bb798788264aa56883956ff;p=neomutt Add a couple missing ATTACHPTR->tree frees. While working on ticket 3800, I noticed the tree wasn't being freed inside OP_COMPOSE_EDIT_HEADERS. Add a free there, and in the cleanup at the end of mutt_compose_menu(). A few other sections in mutt_compose_menu() are performing a free-on-error where the tree isn't allocated yet, so skip it for those. I believe this is actually not fixing a memory leak: all attachments are always at level 0 in the compose menu (as far as I know); so nothing is ever allocated in the tree pointer. However since other parts of the code in compose.c clean this up, it make sense to add them here too. --- diff --git a/compose.c b/compose.c index 7134287b2..a0f9c4ac0 100644 --- a/compose.c +++ b/compose.c @@ -629,7 +629,10 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (idxlen && idx[idxlen - 1]->content->next) { for (i = 0; i < idxlen; i++) + { + FREE (&idx[i]->tree); FREE (&idx[i]); + } idxlen = 0; idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); menu->data = idx; @@ -1321,6 +1324,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ for (i = 0; i < idxlen; i++) { idx[i]->content->aptr = NULL; + FREE (&idx[i]->tree); FREE (&idx[i]); } }