diff --git a/src/libstrongswan/plugins/af_alg/af_alg_hasher.c b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c index 7fac236d4..3b07472fb 100644 --- a/src/libstrongswan/plugins/af_alg/af_alg_hasher.c +++ b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c @@ -119,7 +119,12 @@ METHOD(hasher_t, allocate_hash, bool, if (hash) { *hash = chunk_alloc(get_hash_size(this)); - return get_hash(this, chunk, hash->ptr); + if (!get_hash(this, chunk, hash->ptr)) + { + chunk_free(hash); + return FALSE; + } + return TRUE; } return get_hash(this, chunk, NULL); } diff --git a/src/libstrongswan/plugins/botan/botan_hasher.c b/src/libstrongswan/plugins/botan/botan_hasher.c index d574db0dc..0675fee80 100644 --- a/src/libstrongswan/plugins/botan/botan_hasher.c +++ b/src/libstrongswan/plugins/botan/botan_hasher.c @@ -89,7 +89,12 @@ METHOD(hasher_t, allocate_hash, bool, if (hash) { *hash = chunk_alloc(get_hash_size(this)); - return get_hash(this, chunk, hash->ptr); + if (!get_hash(this, chunk, hash->ptr)) + { + chunk_free(hash); + return FALSE; + } + return TRUE; } return get_hash(this, chunk, NULL); } diff --git a/src/libstrongswan/plugins/openssl/openssl_hasher.c b/src/libstrongswan/plugins/openssl/openssl_hasher.c index cc3b1d1ac..fce1e329a 100644 --- a/src/libstrongswan/plugins/openssl/openssl_hasher.c +++ b/src/libstrongswan/plugins/openssl/openssl_hasher.c @@ -77,7 +77,12 @@ METHOD(hasher_t, allocate_hash, bool, if (hash) { *hash = chunk_alloc(get_hash_size(this)); - return get_hash(this, chunk, hash->ptr); + if (!get_hash(this, chunk, hash->ptr)) + { + chunk_free(hash); + return FALSE; + } + return TRUE; } return get_hash(this, chunk, NULL); } diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_hasher.c b/src/libstrongswan/plugins/wolfssl/wolfssl_hasher.c index 5e9d851c2..cabd06d87 100644 --- a/src/libstrongswan/plugins/wolfssl/wolfssl_hasher.c +++ b/src/libstrongswan/plugins/wolfssl/wolfssl_hasher.c @@ -84,7 +84,12 @@ METHOD(hasher_t, allocate_hash, bool, if (hash) { *hash = chunk_alloc(get_hash_size(this)); - return get_hash(this, chunk, hash->ptr); + if (!get_hash(this, chunk, hash->ptr)) + { + chunk_free(hash); + return FALSE; + } + return TRUE; } return get_hash(this, chunk, NULL); }