From 4cefaf511d9ed79ad13ab59c46bd0ddc60e758f6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 27 Nov 2018 16:30:41 +0100 Subject: [PATCH] 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. --- src/crypto.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) 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); } -- 1.7.1