From: Thomas Roessler Date: Wed, 12 Apr 2000 16:31:37 +0000 (+0000) Subject: Catch some error conditions. X-Git-Tag: mutt-1-1-12-rel~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b75ebf837045ca63adea698b72a6e6acb58fdc56;p=mutt Catch some error conditions. --- diff --git a/headers.c b/headers.c index 38542d79..f9dbef53 100644 --- a/headers.c +++ b/headers.c @@ -86,8 +86,20 @@ void mutt_edit_headers (const char *editor, mutt_free_list (&msg->env->userhdrs); /* Read the temp file back in */ - ifp = fopen (path, "r"); - ofp = safe_fopen (body, "w"); + if ((ifp = fopen (path, "r")) == NULL) + { + mutt_perror (path); + return; + } + + if ((ofp = safe_fopen (body, "w")) == NULL) + { + /* intentionally leak a possible temporary file here */ + fclose (ifp); + mutt_perror (body); + return; + } + n = mutt_read_rfc822_header (ifp, NULL, 1, 0); while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0) fwrite (buffer, 1, i, ofp);