about summary refs log tree commit diff
path: root/malloc/tst-malloc-backtrace.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2022-01-25 15:39:38 -0700
committerMartin Sebor <msebor@redhat.com>2022-01-26 10:38:23 -0700
commitc094c232eb3246154265bb035182f92fe1b17ab8 (patch)
tree4b5d30d81c1870bbda23f9d079be4509fd4d2843 /malloc/tst-malloc-backtrace.c
parente4ba8fee1a8feea62f9f06099a116163848338db (diff)
downloadglibc-c094c232eb3246154265bb035182f92fe1b17ab8.tar.gz
glibc-c094c232eb3246154265bb035182f92fe1b17ab8.tar.xz
glibc-c094c232eb3246154265bb035182f92fe1b17ab8.zip
Avoid -Wuse-after-free in tests [BZ #26779].
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'malloc/tst-malloc-backtrace.c')
-rw-r--r--malloc/tst-malloc-backtrace.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/malloc/tst-malloc-backtrace.c b/malloc/tst-malloc-backtrace.c
index ea66da23ef..65e1a1ffbc 100644
--- a/malloc/tst-malloc-backtrace.c
+++ b/malloc/tst-malloc-backtrace.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 
 #include <support/support.h>
+#include <libc-diag.h>
 
 #define SIZE 4096
 
@@ -29,7 +30,15 @@ __attribute__((noinline))
 call_free (void *ptr)
 {
   free (ptr);
+#if __GNUC_PREREQ (12, 0)
+  /* Ignore a valid warning about using a pointer made indeterminate
+     by a prior call to free().  */
+  DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
   *(size_t *)(ptr - sizeof (size_t)) = 1;
+#if __GNUC_PREREQ (12, 0)
+  DIAG_POP_NEEDS_COMMENT;
+#endif
 }
 
 int