From eef86dfd9b979eabee874595251517afe40b196b Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 10 Mar 2015 13:05:13 +0000 Subject: Behave in an OpenBSD compatible way for 0. --- lib/libc/stdlib/reallocarray.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdlib/reallocarray.c') diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c index 7cf710421a1..6a93bd1106f 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) -- cgit