From 5518fe9be123bc1e255dc05334e1e744459aa288 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sun, 20 Feb 2011 13:34:53 +0000 Subject: [PATCH] grep - letting calloc() return NULL for 0 storage makes grep "" work --- commands/grep/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }