crypto/mem.c: set *freeptr on posix_memalign failure

Initialise *freeptr when posix_memalign fails, so the free(freeptr)
idiom can be used unconditionally in all cases by the callers.

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
This commit is contained in:
Eugene Syromiatnikov 2025-07-25 03:48:23 +02:00
parent 4bf0b8af2f
commit ac9a52716c
1 changed files with 1 additions and 1 deletions

View File

@ -256,7 +256,7 @@ void *CRYPTO_aligned_alloc(size_t num, size_t alignment, void **freeptr,
if (malloc_impl == CRYPTO_malloc) {
#if defined(_BSD_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
if (posix_memalign(&ret, alignment, num))
return NULL;
ret = NULL;
*freeptr = ret;
return ret;
#elif defined(_ISOC11_SOURCE)