From ece1e2153508ced72c93bd4fc7de2615701b8b01 Mon Sep 17 00:00:00 2001 From: Tyrolyean Date: Sat, 25 Apr 2020 01:55:49 +0200 Subject: [PATCH] Moved file close Signed-off-by: Tyrolyean --- src/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index f49be34..2493e57 100644 --- a/src/main.c +++ b/src/main.c @@ -40,17 +40,13 @@ sfsistat mlfi_cleanup(SMFICTX* ctx, bool ok) { return rstat; } - /* close the archive file */ - if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp) == EOF){ - /* failed; we have to wait until later */ - rstat = SMFIS_TEMPFAIL; - (void) unlink(priv->mlfi_fname); - } else if (ok){ + if (ok){ /* add a header to the message announcing our presence */ smfi_addheader(ctx, "X-Mail-Attached", VERSION); /* replace body if attachements have been found */ + char* new_body = attach_files(priv->mlfi_fp); if(new_body != NULL){ @@ -68,7 +64,12 @@ sfsistat mlfi_cleanup(SMFICTX* ctx, bool ok) { } } } - + /* close the archive file */ + if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp) == EOF){ + /* failed; we have to wait until later */ + rstat = SMFIS_TEMPFAIL; + (void) unlink(priv->mlfi_fname); + } /* In any case release the temporary data storage file */ (void) unlink(priv->mlfi_fname);