1 file changed, 14 insertions(+), 12 deletions(-) sendlib.c | 26 ++++++++++++++------------
# HG changeset patch # User Erik Hovland <e...@hovland.org> # Date 1237420329 25200 # Branch HEAD # Node ID 1b97d4b561846e0d77e8216bde94f7c2637a0149 # Parent 9ccf56c08a039ffa448fbd3f34c659a19fcb6ae4 Fix various resource leaks throughout sendlib.c diff --git a/sendlib.c b/sendlib.c --- a/sendlib.c +++ b/sendlib.c @@ -828,7 +828,7 @@ for (i = 0; i < ncodes; i++) FREE (&tcode[i]); - FREE (tcode); /* __FREE_CHECKED__ */ + FREE (&tcode); /* __FREE_CHECKED__ */ return ret; } @@ -1069,7 +1069,7 @@ cleanup: FREE (&line); - if (fpin && !fp) + if (fpin && fpin != fp) safe_fclose (&fpin); if (fpout) safe_fclose (&fpout); @@ -1385,6 +1385,7 @@ } } + FREE (&info); mutt_update_encoding (att); return (att); } @@ -2395,6 +2396,7 @@ { mutt_error (_("Bad IDN %s while preparing resent-from."), err); + rfc822_free_address (&from); return -1; } rfc822_write_address (resent_from, sizeof (resent_from), from, 0); @@ -2467,7 +2469,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc) { - CONTEXT f; + CONTEXT *f = NULL; MESSAGE *msg; char tempfile[_POSIX_PATH_MAX]; FILE *tempfp = NULL; @@ -2476,7 +2478,7 @@ if (post) set_noconv_flags (hdr->content, 1); - if (mx_open_mailbox (path, M_APPEND | M_QUIET, &f) == NULL) + if ((f = mx_open_mailbox (path, M_APPEND | M_QUIET, f)) == NULL) { dprint (1, (debugfile, "mutt_write_fcc(): unable to open mailbox %s in append-mode, aborting.\n", path)); @@ -2486,21 +2488,21 @@ /* We need to add a Content-Length field to avoid problems where a line in * the message body begins with "From " */ - if (f.magic == M_MMDF || f.magic == M_MBOX) + if (f->magic == M_MMDF || f->magic == M_MBOX) { mutt_mktemp (tempfile); if ((tempfp = safe_fopen (tempfile, "w+")) == NULL) { mutt_perror (tempfile); - mx_close_mailbox (&f, NULL); + mx_close_mailbox (f, NULL); return (-1); } } hdr->read = !post; /* make sure to put it in the `cur' directory (maildir) */ - if ((msg = mx_open_new_message (&f, hdr, M_ADD_FROM)) == NULL) + if ((msg = mx_open_new_message (f, hdr, M_ADD_FROM)) == NULL) { - mx_close_mailbox (&f, NULL); + mx_close_mailbox (f, NULL); return (-1); } @@ -2606,9 +2608,9 @@ dprint (1, (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile)); safe_fclose (&tempfp); unlink (tempfile); - mx_commit_message (msg, &f); /* XXX - really? */ + mx_commit_message (msg, f); /* XXX - really? */ mx_close_message (&msg); - mx_close_mailbox (&f, NULL); + mx_close_mailbox (f, NULL); return -1; } @@ -2634,10 +2636,10 @@ r = mutt_write_mime_body (hdr->content, msg->fp); } - if (mx_commit_message (msg, &f) != 0) + if (mx_commit_message (msg, f) != 0) r = -1; mx_close_message (&msg); - mx_close_mailbox (&f, NULL); + mx_close_mailbox (f, NULL); if (post) set_noconv_flags (hdr->content, 0);