diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test-skeleton.c | 6 |
2 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,9 @@ 2016-06-23 Florian Weimer <fweimer@redhat.com> + * test-skeleton.c (xrealloc): Support deallocation with n == 0. + +2016-06-23 Florian Weimer <fweimer@redhat.com> + * test-skeleton.c (xmalloc, xcalloc, xrealloc): Mark as potentially unused. diff --git a/test-skeleton.c b/test-skeleton.c index 0be4af1..d9bf989 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 |