Otherwise the counting done by shouldfail() does not account for calls
that are diverted to non-standard implementation and zero-sized
allocations, making it diverge from the sum of malloc_count
and realloc_count.
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Apr 30 06:59:07 2026
(Merged from https://github.com/openssl/openssl/pull/30991)
void *ptr;
INCREMENT(malloc_count);
+ FAILTEST();
if (malloc_impl != CRYPTO_malloc) {
ptr = malloc_impl(num, file, line);
if (ptr != NULL || num == 0)
if (ossl_unlikely(num == 0))
return NULL;
- FAILTEST();
if (allow_customize) {
/*
* Disallow customization after the first allocation. We only set this
void *ret;
INCREMENT(realloc_count);
+ FAILTEST();
if (realloc_impl != CRYPTO_realloc) {
ret = realloc_impl(str, num, file, line);
return NULL;
}
- FAILTEST();
ret = realloc(str, num);
err:
Before OpenSSL 4.0, the call to OPENSSL_aligned_alloc() did not have
an explicit upper limit on the value of I<alignment>.
+Before OpenSSL 4.1, allocations done by custom memory functions
+and zero-sized allocations did not progress allocation counter
+used against B<OPENSSL_MALLOC_FAILURES> specification.
+
=head1 COPYRIGHT
Copyright 2016-2025 The OpenSSL Project Authors. All Rights Reserved.