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:
Nick Mathewson 2012-02-28 14:49:47 -05:00
parent 7bcac07d5a
commit af7ba6955e

11
event.c
View File

@ -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;