From bde5df19d88abb58fab0e6e34c496e125f777b23 Mon Sep 17 00:00:00 2001 From: Richard Walmsley Date: Thu, 1 Jan 2015 13:56:12 +1300 Subject: [PATCH] Example program will now close the attachment file when successful. --- example.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/example.c b/example.c index d9d6e11..6b35db2 100644 --- a/example.c +++ b/example.c @@ -152,9 +152,13 @@ static int ReadAttach(FILE **File, void *Buffer, unsigned int BufferSize) Result = fread(Buffer, 1, BufferSize, *File); - if (Result != BufferSize && ferror(*File)) { - CloseAttach(File); - return -1; + if (Result != BufferSize) { + if (ferror(*File)) { + CloseAttach(File); + return -1; + } + else if (!Result && feof(*File)) + CloseAttach(File); } return Result;