Resolve hash new leak due to improper heap hint check. Make sure isAllocated is initialized to 0.

This commit is contained in:
David Garske
2024-09-24 17:01:42 -07:00
parent 7989dd8713
commit 0bb41e1eb4

View File

@ -710,6 +710,7 @@ int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
if (hash == NULL)
return BAD_FUNC_ARG;
hash->isAllocated = 0;
switch (type) {
case WC_HASH_TYPE_MD5:
#ifndef NO_MD5
@ -1146,8 +1147,9 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
ret = BAD_FUNC_ARG;
};
if (isAllocated && heap)
if (isAllocated) {
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
}
return ret;
}