scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 11a1e2b9c41e87270850da65b4203f8a270b8384
parent 2ec31560621723e31191aa91d93f9ffa9e199d28
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 10 Dec 2022 16:24:18 +0100

libc/calloc: Use SIZE_MAX instead of (size_t)-1

Diffstat:
Msrc/libc/stdlib/calloc.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libc/stdlib/calloc.c b/src/libc/stdlib/calloc.c @@ -1,5 +1,6 @@ #include <stdlib.h> #include <string.h> +#include <stdint.h> #undef calloc @@ -9,7 +10,7 @@ calloc(size_t nmemb, size_t size) size_t nbytes; void *mem; - if (!nmemb || !size || nmemb > (size_t)-1/size) + if (!nmemb || !size || nmemb > SIZE_MAX/size) return NULL; nbytes = nmemb * size;