diff --git a/crypto/test/malloc.cc b/crypto/test/malloc.cc index 9ffdf014..31da2c78 100644 --- a/crypto/test/malloc.cc +++ b/crypto/test/malloc.cc @@ -34,6 +34,7 @@ #if defined(__linux__) && defined(OPENSSL_GLIBC) && !defined(OPENSSL_ARM) && \ !defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN) +#include #include #include #include @@ -118,6 +119,7 @@ extern "C" { void *malloc(size_t size) { if (should_fail_allocation()) { + errno = ENOMEM; return NULL; } @@ -126,6 +128,7 @@ void *malloc(size_t size) { void *calloc(size_t num_elems, size_t size) { if (should_fail_allocation()) { + errno = ENOMEM; return NULL; } @@ -134,6 +137,7 @@ void *calloc(size_t num_elems, size_t size) { void *realloc(void *ptr, size_t size) { if (should_fail_allocation()) { + errno = ENOMEM; return NULL; }