From 45d118101a3a47446310b28bfae85334686cbe06 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Wed, 6 Sep 2023 13:22:07 +0200 Subject: [PATCH] Added assertion test for the buffer alignment padding size. --- library/stdio_setvbuf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/stdio_setvbuf.c b/library/stdio_setvbuf.c index 5120a25..e138ba4 100644 --- a/library/stdio_setvbuf.c +++ b/library/stdio_setvbuf.c @@ -125,6 +125,8 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) allocate some memory for it. */ if(size > 0 && buf == NULL) { + assert( size <= ((size + (__cache_line_size-1)) & ~(__cache_line_size-1)) ); + /* Allocate a little more memory than necessary. */ new_buffer = malloc(size + (__cache_line_size-1)); if(new_buffer == NULL)