Skip to content

Commit 0bb41e1

Browse files
committed
Resolve hash new leak due to improper heap hint check. Make sure isAllocated is initialized to 0.
1 parent 7989dd8 commit 0bb41e1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

wolfcrypt/src/hash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
710710
if (hash == NULL)
711711
return BAD_FUNC_ARG;
712712

713+
hash->isAllocated = 0;
713714
switch (type) {
714715
case WC_HASH_TYPE_MD5:
715716
#ifndef NO_MD5
@@ -1146,8 +1147,9 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
11461147
ret = BAD_FUNC_ARG;
11471148
};
11481149

1149-
if (isAllocated && heap)
1150+
if (isAllocated) {
11501151
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
1152+
}
11511153

11521154
return ret;
11531155
}

0 commit comments

Comments
 (0)