aboutsummaryrefslogtreecommitdiffstats
path: root/argon2/hash.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-14 18:53:23 +0200
committerMattias Andrée <m@maandree.se>2026-05-14 18:53:23 +0200
commitcd2620916f88396924fc6befa0c990080bf5046c (patch)
treefffe4f6771840d2511955d6637fd45279b3e38f6 /argon2/hash.c
parentFix libtest (diff)
downloadlibrecrypt-cd2620916f88396924fc6befa0c990080bf5046c.tar.gz
librecrypt-cd2620916f88396924fc6befa0c990080bf5046c.tar.bz2
librecrypt-cd2620916f88396924fc6befa0c990080bf5046c.tar.xz
Fix memory leak
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--argon2/hash.c7
1 files changed, 6 insertions, 1 deletions
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)