aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/use-after-free-3.c
blob: d8eeb1741138676c6645c8645da85edb8107737a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */

#include <stdlib.h>

void test_1 (int x, int y, int *out)
{
  int *ptr = (int *)malloc (sizeof (int));
  if (!ptr)
    return;
  *ptr = 19;

  free (ptr);
  *out = *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */
}