From f2e8b2ad792bd6b494f0af19b292bc9670014921 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Thu, 15 Feb 2024 00:56:54 +0100 Subject: [PATCH] bcheck: fix argument order for memalign Spotted by George Sedov on the mailing list. The bug was in the tcc source since >20 years: https://repo.or.cz/tinycc.git?a=commit;h=ad28d4c5b03da27dc0381afb58f255d49962cca0 manpage for memalign: https://linux.die.net/man/3/memalign -- Regards ... Detlef --- lib/bcheck.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bcheck.c b/lib/bcheck.c index 1e374f16..f609a228 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -323,7 +323,7 @@ DLL_EXPORT void *__aeabi_memset(void *dst, int c, size_t size); #define BOUND_REALLOC(a,b) realloc(a,b) #define BOUND_CALLOC(a,b) calloc(a,b) DLL_EXPORT void *__bound_malloc(size_t size, const void *caller); -DLL_EXPORT void *__bound_memalign(size_t size, size_t align, const void *caller); +DLL_EXPORT void *__bound_memalign(size_t align, size_t size, const void *caller); DLL_EXPORT void __bound_free(void *ptr, const void *caller); DLL_EXPORT void *__bound_realloc(void *ptr, size_t size, const void *caller); DLL_EXPORT void *__bound_calloc(size_t nmemb, size_t size); @@ -1519,9 +1519,9 @@ void *__bound_malloc(size_t size, const void *caller) } #if MALLOC_REDIR -void *memalign(size_t size, size_t align) +void *memalign(size_t align, size_t size) #else -void *__bound_memalign(size_t size, size_t align, const void *caller) +void *__bound_memalign(size_t align, size_t size, const void *caller) #endif { void *ptr; @@ -1530,7 +1530,7 @@ void *__bound_memalign(size_t size, size_t align, const void *caller) /* we allocate one more byte to ensure the regions will be separated by at least one byte. With the glibc malloc, it may be in fact not necessary */ - ptr = BOUND_MEMALIGN(size + 1, align); + ptr = BOUND_MEMALIGN(align, size + 1); #else if (align > 4) { /* XXX: handle it ? */