blob: 7410a717762bd14481c903807ec3656b56dceeca (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <stdlib.h>
void __attribute__((noinline)) callee_1 (int *ptr)
{
*ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
}
int test_1 (int i, int flag)
{
/* Double diamond CFG; either use &i, or a malloc-ed buffer. */
int *ptr = &i;
if (flag)
ptr = (int *)malloc (sizeof (int));
callee_1 (ptr);
if (flag)
free (ptr);
return i;
}
void __attribute__((noinline)) callee_2 (int *ptr)
{
*ptr = 42;
}
int test_2 (int flag)
{
int i;
if (flag)
callee_2 (&i);
callee_2 (&i);
if (!flag)
{
void *ptr = malloc (16);
free (ptr);
free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */
}
}
|