diff options
| author | christos <christos@NetBSD.org> | 2015-03-10 13:05:13 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2015-03-10 13:05:13 +0000 |
| commit | eef86dfd9b979eabee874595251517afe40b196b (patch) | |
| tree | ae5ea897658b737c69ee418d3e0b3bc905b03def /lib/libc/stdlib/reallocarray.c | |
| parent | 2ad5e7517e3fba9bb08f8d0621bab0821145f9b9 (diff) | |
Behave in an OpenBSD compatible way for 0.
Diffstat (limited to 'lib/libc/stdlib/reallocarray.c')
| -rw-r--r-- | lib/libc/stdlib/reallocarray.c | 5 |
1 files changed, 4 insertions, 1 deletions
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 <sys/cdefs.h> -__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 <errno.h> @@ -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) |
