Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Behave in an OpenBSD compatible way for 0.



details:   https://anonhg.NetBSD.org/src/rev/339a392f531c
branches:  trunk
changeset: 336685:339a392f531c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 10 13:05:13 2015 +0000

description:
Behave in an OpenBSD compatible way for 0.

diffstat:

 lib/libc/stdlib/reallocarray.c |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (22 lines):

diff -r 0851094f32dc -r 339a392f531c lib/libc/stdlib/reallocarray.c
--- a/lib/libc/stdlib/reallocarray.c    Tue Mar 10 13:00:58 2015 +0000
+++ b/lib/libc/stdlib/reallocarray.c    Tue Mar 10 13:05:13 2015 +0000
@@ -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 @@
 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)



Home | Main Index | Thread Index | Old Index