]> Zhao Yanbai Git Server - minix.git/commitdiff
grep - letting calloc() return NULL for 0 storage makes grep "" work
authorBen Gras <ben@minix3.org>
Sun, 20 Feb 2011 13:34:53 +0000 (13:34 +0000)
committerBen Gras <ben@minix3.org>
Sun, 20 Feb 2011 13:34:53 +0000 (13:34 +0000)
commands/grep/util.c

index 028ddc6fd3c9d8fb4c55100d53f1857668bcd777..bbfff156925d163de43ea638b4cea2dee4258b9b 100644 (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;
 }