Commit
43a37bedd934bde50a6441766b85dfc9648abda9 added a `calloc` wrapper but
mistakenly did not account for it being valid for `calloc` to return `NULL` when
the input arguments are 0. This is unlikely to have caused a problem with Glibc
whose allocator typically returns non-null pointers even for 0 allocations.
However assuming a 0 allocation may return a null pointer is more portable.
directory #2101
- the generated gdefs.h header is no longer installed
- `ccomps` out-of-memory message no longer incorrectly refers to `gc`
+- do not abort when `calloc(0, x)` or `calloc(x, 0)` in `gcalloc` return `NULL`
## [2.48.0] - 2021-07-17
void *gcalloc(size_t nmemb, size_t size)
{
char *rv = calloc(nmemb, size);
- if (UNLIKELY(rv == NULL)) {
+ if (UNLIKELY(nmemb > 0 && size > 0 && rv == NULL)) {
fprintf(stderr, "out of memory\n");
exit(EXIT_FAILURE);
}