From cd2620916f88396924fc6befa0c990080bf5046c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 14 May 2026 18:53:23 +0200 Subject: Fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- argon2/hash.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'argon2/hash.c') diff --git a/argon2/hash.c b/argon2/hash.c index c63ba67..313eea0 100644 --- a/argon2/hash.c +++ b/argon2/hash.c @@ -140,6 +140,10 @@ librecrypt__argon2__hash(char *restrict out_buffer, size_t size, const char *phr fail: saved_errno = errno; + if (scratch) { + librecrypt_wipe(scratch, scratch_size); + free(scratch); + } if (salt) { librecrypt_wipe(salt, saltlen); free(salt); @@ -210,7 +214,8 @@ check(const char *phrase, const char *settings, const char *hash, size_t hashlen errno = 0;\ EXPECT(librecrypt__argon2__hash(NULL, 0u, NULL, (size_t)UINT32_MAX + 1u,\ S(ALGO"m=1024,t=10,p=1$ABCDabcdABCDabcd$"), NULL) == -1);\ - EXPECT(errno == EINVAL) + EXPECT(errno == EINVAL);\ + libtest_set_alloc_failure_in(0u) #else # define CHECK_MEGAPASSPHRASE(ALGO)\ ((void)0) -- cgit v1.2.3-70-g09d2