1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Avoid -Wuse-after-free in tests [BZ #26779].

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Martin Sebor
2022-01-25 15:39:38 -07:00
parent e4ba8fee1a
commit c094c232eb
6 changed files with 60 additions and 2 deletions

View File

@ -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