From e4424a2c65fee72dd06955f23d68dfd889fb191a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 31 Oct 2024 20:54:41 +0100 Subject: [PATCH] realloc-posix tests: Fix memory leak. * tests/test-realloc-posix.c (main): Don't clobber variable 'p' in failing call. --- ChangeLog | 6 ++++++ tests/test-realloc-posix.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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_")) -- 2.39.5