aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/callbacks-1.c
blob: 763027c714ae9f788af65e725fcd42ba8c6c7106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */

/* Reproducer for PR analyzer/97258: we should report the double-free
   inside a static callback if the callback escapes.  */

#include <stdlib.h>

static void callback_1 (void *p)
{
  free (p);
  free (p); /* { dg-warning "double-'free' of 'p'" } */
}

struct ops {
  void (*cb) (void *);
};

static const struct ops ops_1 = {
  .cb = callback_1
};

extern void registration (const void *);

void register_1 (void)
{
  registration (&ops_1);
}