From: Bruno Haible Date: Thu, 31 Oct 2024 19:54:41 +0000 (+0100) Subject: realloc-posix tests: Fix memory leak. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e4424a2c65fee72dd06955f23d68dfd889fb191a;p=gnulib.git realloc-posix tests: Fix memory leak. * tests/test-realloc-posix.c (main): Don't clobber variable 'p' in failing call. --- diff --git a/ChangeLog b/ChangeLog index c239e373fe..8cc43c210d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-10-31 Bruno Haible + + realloc-posix tests: Fix memory leak. + * tests/test-realloc-posix.c (main): Don't clobber variable 'p' in + failing call. + 2024-10-31 Bruno Haible calloc-posix: Add tests. diff --git a/tests/test-realloc-posix.c b/tests/test-realloc-posix.c index 79d430b95a..0deb78c699 100644 --- a/tests/test-realloc-posix.c +++ b/tests/test-realloc-posix.c @@ -52,8 +52,8 @@ main (int argc, _GL_UNUSED char **argv) if (PTRDIFF_MAX < SIZE_MAX) { size_t one = argc != 12345; - p = realloc (p, PTRDIFF_MAX + one); - ASSERT (p == NULL); + void *volatile r = realloc (p, PTRDIFF_MAX + one); + ASSERT (r == NULL); /* Avoid a test failure due to glibc bug . */ if (!getenv ("MALLOC_CHECK_"))