]> Savannah Git Hosting - gnulib.git/commitdiff
realloc-posix tests: Fix memory leak.
authorBruno Haible <bruno@clisp.org>
Thu, 31 Oct 2024 19:54:41 +0000 (20:54 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 31 Oct 2024 19:54:41 +0000 (20:54 +0100)
* tests/test-realloc-posix.c (main): Don't clobber variable 'p' in
failing call.

ChangeLog
tests/test-realloc-posix.c

index c239e373fedbe2e4db9946cfe981ac8011d1f9d3..8cc43c210d5fda6d01530f586dc8ba040e5b7d71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-10-31  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        calloc-posix: Add tests.
index 79d430b95a39de6ed83e248552cc72927b13e0dc..0deb78c6995592cfa50aca3400f96fb6b07819ac 100644 (file)
@@ -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
          <https://sourceware.org/bugzilla/show_bug.cgi?id=27870>.  */
       if (!getenv ("MALLOC_CHECK_"))