mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Check for NULL return on win32 mm_calloc, and set ENOMEM.
(It looks like windows doesn't set ENOMEM on overflow from calloc.)
This commit is contained in:
parent
7bcac07d5a
commit
af7ba6955e
11
event.c
11
event.c
@ -2827,8 +2827,15 @@ event_mm_calloc_(size_t count, size_t size)
|
||||
p = _mm_malloc_fn(sz);
|
||||
if (p)
|
||||
return memset(p, 0, sz);
|
||||
} else
|
||||
return calloc(count, size);
|
||||
} else {
|
||||
void *p = calloc(count, size);
|
||||
#ifdef _WIN32
|
||||
/* Windows calloc doesn't reliably set ENOMEM */
|
||||
if (p == NULL)
|
||||
goto error;
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
error:
|
||||
errno = ENOMEM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user