summaryrefslogtreecommitdiff
path: root/gnu/dist/diffutils/lib/xmalloc.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2012-03-12 17:41:59 +0000
committerchristos <christos@NetBSD.org>2012-03-12 17:41:59 +0000
commitf4cccb2837124fd0514bade274e9c7d12d0b9f9b (patch)
tree37589fdc936f4b3c4211ef62b1fca3ce8cec2e66 /gnu/dist/diffutils/lib/xmalloc.c
parentf23124059f7f4eca07678f7e1b7e0e50dba8af10 (diff)
PR/26453: Ken Raeburn: make zero byte allocations return NULL instead of error
out.
Diffstat (limited to 'gnu/dist/diffutils/lib/xmalloc.c')
-rw-r--r--gnu/dist/diffutils/lib/xmalloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gnu/dist/diffutils/lib/xmalloc.c b/gnu/dist/diffutils/lib/xmalloc.c
index 5796053b900..ce33c1aa7f7 100644
--- a/gnu/dist/diffutils/lib/xmalloc.c
+++ b/gnu/dist/diffutils/lib/xmalloc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: xmalloc.c,v 1.1.1.1 2003/01/26 00:43:15 wiz Exp $ */
+/* $NetBSD: xmalloc.c,v 1.2 2012/03/12 17:41:59 christos Exp $ */
/* xmalloc.c -- malloc with out of memory checking
Copyright (C) 1990-1999, 2000, 2002 Free Software Foundation, Inc.
@@ -84,7 +84,7 @@ xmalloc (size_t n)
void *p;
p = malloc (n);
- if (p == 0)
+ if (p == 0 && n)
xalloc_die ();
return p;
}
@@ -96,7 +96,7 @@ void *
xrealloc (void *p, size_t n)
{
p = realloc (p, n);
- if (p == 0)
+ if (p == 0 && n)
xalloc_die ();
return p;
}
@@ -109,7 +109,7 @@ xcalloc (size_t n, size_t s)
void *p;
p = calloc (n, s);
- if (p == 0)
+ if (p == 0 && n && s)
xalloc_die ();
return p;
}