From: Ben Gras Date: Sun, 20 Feb 2011 13:34:53 +0000 (+0000) Subject: grep - letting calloc() return NULL for 0 storage makes grep "" work X-Git-Tag: v3.2.0~661 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch01.html?a=commitdiff_plain;h=5518fe9be123bc1e255dc05334e1e744459aa288;p=minix.git grep - letting calloc() return NULL for 0 storage makes grep "" work --- diff --git a/commands/grep/util.c b/commands/grep/util.c index 028ddc6fd..bbfff1569 100644 --- a/commands/grep/util.c +++ b/commands/grep/util.c @@ -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; }