aboutsummaryrefslogtreecommitdiff
path: root/test-skeleton.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-06-23 14:17:57 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-06-23 16:12:48 +0200
commit64ba17317dc9343f0958755ad04af71ec3da637b (patch)
tree9e6cecd5901282bc570be7f392a601cc52cfe1fc /test-skeleton.c
parent9d52cb01f253c84e177fe2db8386deaea06a2596 (diff)
downloadglibc-64ba17317dc9343f0958755ad04af71ec3da637b.tar
glibc-64ba17317dc9343f0958755ad04af71ec3da637b.tar.gz
glibc-64ba17317dc9343f0958755ad04af71ec3da637b.tar.bz2
glibc-64ba17317dc9343f0958755ad04af71ec3da637b.zip
test-skeleton.c (xrealloc): Support realloc-as-free
If the requested size is zero, realloc returns NULL, but the deallocation is still successful, unless the pointer is also NULL, when realloc behaves as malloc (0).
Diffstat (limited to 'test-skeleton.c')
-rw-r--r--test-skeleton.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/test-skeleton.c b/test-skeleton.c
index 0be4af1daf..d9bf989fa8 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -109,10 +109,10 @@ __attribute__ ((unused))
static void *
xrealloc (void *p, size_t n)
{
- p = realloc (p, n);
- if (p == NULL)
+ void *result = realloc (p, n);
+ if (result == NULL && (n > 0 || p == NULL))
oom_error ("realloc", n);
- return p;
+ return result;
}
/* Write a message to standard output. Can be used in signal