From 59469ea9107cb75ec60abf14440292ea691ab194 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 1 Dec 2024 10:21:13 +0100 Subject: mail_file_to_address: added missing call to pclose() and moved the fprintf() call --- FICS/utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'FICS/utils.c') diff --git a/FICS/utils.c b/FICS/utils.c index ced5c6c..d9fac79 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -218,9 +218,13 @@ mail_file_to_address(char *addr, char *subj, char *fname) if ((fp1 = popen(com, "w")) == NULL) return -1; #ifdef SENDMAILPROG - fprintf(fp1, "To: %s\nSubject: %s\n", addr, subj); - if ((fp2 = fopen(fname, "r")) == NULL) // XXX + if ((fp2 = fopen(fname, "r")) == NULL) { + pclose(fp1); return -1; + } + + fprintf(fp1, "To: %s\nSubject: %s\n", addr, subj); + while (fgets(tmp, sizeof tmp, fp2) != NULL && !feof(fp2)) fputs(tmp, fp1); fclose(fp2); -- cgit v1.2.3