grep - letting calloc() return NULL for 0 storage makes grep "" work

This commit is contained in:
Ben Gras 2011-02-20 13:34:53 +00:00
parent 32f3d9842d
commit 5518fe9be1

View file

@ -516,7 +516,7 @@ grep_calloc(size_t nmemb, size_t size)
{
void *ptr;
if ((ptr = calloc(nmemb, size)) == NULL)
if ((ptr = calloc(nmemb, size)) == NULL && (size > 0) && (nmemb > 0))
err(2, "calloc");
return ptr;
}