From 968c135966e5c695aed4e7436babde234305f1f3 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Wed, 31 Jul 2002 09:19:04 +0000 Subject: [PATCH] permit calloc(0, N) and calloc(N, 0) -- malloc(0) does the right thing; markus miod ok --- src/lib/libc/stdlib/calloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/libc/stdlib/calloc.c b/src/lib/libc/stdlib/calloc.c index c53b22b4..c75b256d 100644 --- a/src/lib/libc/stdlib/calloc.c +++ b/src/lib/libc/stdlib/calloc.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: calloc.c,v 1.6 2002/07/30 00:11:07 deraadt Exp $"; +static char *rcsid = "$OpenBSD: calloc.c,v 1.7 2002/07/31 09:19:04 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -47,7 +47,7 @@ calloc(num, size) { register void *p; - if (SIZE_T_MAX / num < size) { + if (num && size && SIZE_T_MAX / num < size) { errno = ENOMEM; return NULL; }