From f7b1663b18dc2cb5ca9cd66ea2830db9cec9efc7 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 10 Mar 2015 13:05:13 +0000 Subject: [PATCH] Behave in an OpenBSD compatible way for 0. --- lib/libc/stdlib/reallocarray.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c index 7cf710421a1f..6a93bd1106fa 100644 --- a/lib/libc/stdlib/reallocarray.c +++ b/lib/libc/stdlib/reallocarray.c @@ -30,7 +30,7 @@ */ #define _OPENBSD_SOURCE #include -__RCSID("$NetBSD: reallocarray.c,v 1.3 2015/02/17 20:44:42 christos Exp $"); +__RCSID("$NetBSD: reallocarray.c,v 1.4 2015/03/10 13:05:13 christos Exp $"); #define _OPENBSD_SOURCE #include @@ -39,6 +39,9 @@ __RCSID("$NetBSD: reallocarray.c,v 1.3 2015/02/17 20:44:42 christos Exp $"); void * reallocarray(void *optr, size_t nmemb, size_t size) { + if (nmemb == 0 || size == 0) + return realloc(optr, 0); + int e = reallocarr(&optr, nmemb, size); if (e == 0)