]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Close some open files in email.c
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 4 Oct 2014 15:14:14 +0000 (17:14 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 4 Oct 2014 15:14:14 +0000 (17:14 +0200)
This is patch #38 submitted by T.M. Abraham. Many thanks.

email.c

diff --git a/email.c b/email.c
index c3ddf30144891b39d7561785b22f365e23b7f5f7..c32608ef1a6cd89c5c9e9dbacf6aa7acd6bf95fe 100644 (file)
--- a/email.c
+++ b/email.c
@@ -62,12 +62,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                exit(EXIT_FAILURE);
        }
 
-       snprintf(top1,sizeof(top1),"%s/top",dirname);
-       if((fp_top1=fopen(top1,"w"))==NULL) {
-               debuga(_("(email) Cannot open file %s: %s\n"),top1,strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-
        snprintf(top2,sizeof(top2),"%s/top.tmp",dirname);
        if((fp_top2=fopen(top2,"w"))==NULL) {
                debuga(_("(email) Cannot open file %s: %s\n"),top2,strerror(errno));
@@ -278,6 +272,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 
                while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
                        fputs(warea,stdout);
+               if (fclose(fp_top3)==EOF) {
+                       debuga(_("Read error in temporary mail file %s: %s\n"),top3,strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
        } else {
                /* TRANSLATORS: The string is formatted using strftime. You can use
                   any string formatting marker allowed by strftime. */