From: Nathan Moinvaziri Date: Sun, 7 Jan 2024 01:15:06 +0000 (-0800) Subject: Memory alloc size must be a multiple of alignment for aligned_alloc. X-Git-Tag: 2.2.0~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a03576b34d76f48ae03d669b17997aeebd80cc4;p=thirdparty%2Fzlib-ng.git Memory alloc size must be a multiple of alignment for aligned_alloc. --- diff --git a/zutil_p.h b/zutil_p.h index bc6f9698..97799f0c 100644 --- a/zutil_p.h +++ b/zutil_p.h @@ -17,6 +17,8 @@ /* Function to allocate 16 or 64-byte aligned memory */ static inline void *zng_alloc(size_t size) { #ifdef HAVE_ALIGNED_ALLOC + /* Size must be a multiple of alignment */ + size = (size + (64 - 1)) & ~(64 - 1); return (void *)aligned_alloc(64, size); /* Defined in C11 */ #elif defined(HAVE_POSIX_MEMALIGN) void *ptr;