From: Philipp Gesang Date: Tue, 27 Nov 2018 15:30:41 +0000 (+0100) Subject: stop leaking FILE* objects when hashing X-Git-Tag: v2.11~2 X-Git-Url: http://developer.intra2net.com/git/?p=libi2ncommon;a=commitdiff_plain;h=4cefaf511d9ed79ad13ab59c46bd0ddc60e758f6 stop leaking FILE* objects when hashing In hash_file(), the input FILE* needs freeing when no error occurred. Do this as soon as it is not needed anymore. --- diff --git a/src/crypto.cpp b/src/crypto.cpp index d08f5d6..2aeb614 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -168,9 +168,10 @@ string I2n::hash_file(string filename, algorithm algo) } } + fclose(file); + if (!EVP_DigestFinal_ex(ctx.get(), ret.get(), &olen)) { - fclose(file); throw runtime_error(ERROR_MESSAGE); }