fix calloc

This commit is contained in:
Stefano D'Angelo 2024-03-26 21:51:15 +01:00
parent 119ae86ec4
commit ff8a589019

View File

@ -127,7 +127,7 @@ void *realloc(void *ptr, size_t size) {
}
void *calloc(size_t nmemb, size_t size) {
if (nmemb == 0 || SIZE_MAX / nmemb > size || (SIZE_MAX / nmemb == size && SIZE_MAX % nmemb != 0))
if (nmemb == 0 || SIZE_MAX / nmemb < size || (SIZE_MAX / nmemb == size && SIZE_MAX % nmemb != 0))
return NULL;
size_t s = nmemb * size;
void *m = malloc(s);