mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Resolve hash new leak due to improper heap hint check. Make sure isAllocated is initialized to 0.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user