[Bug 269688] memalign() produces division by zero if size is 0
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 269688] memalign() produces division by zero if size is 0"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 19 Feb 2023 17:14:00 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269688 --- Comment #2 from Paul Floyd <pjfloyd@wanadoo.fr> --- On other platforms the behaviour is: macOS doesn't exist Linux glibc just calls malloc https://elixir.bootlin.com/glibc/glibc-2.37.9000/source/malloc/malloc.c#L3510 /* If we need less alignment than we give anyway, just relay to malloc. */ if (alignment <= MALLOC_ALIGNMENT) return __libc_malloc (bytes); musl just calls malloc https://github.com/esmil/musl/blob/master/src/malloc/memalign.c if (align <= 4*sizeof(size_t)) { if (!(mem = malloc(len))) return NULL; return mem; } illimos sets EINVAL and returns NULL https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/gen/memalign.c /* * check for valid size and alignment parameters * MAX_ALIGN check prevents overflow in later calculation. */ if (nbytes == 0 || _misaligned(align) || align == 0 || align > MAX_ALIGN) { errno = EINVAL; return (NULL); } -- You are receiving this mail because: You are the assignee for the bug.