Daily bump.
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / leak-pr109059-1.c
blobae196d75b935d28016cf9a0a9fbf7b700e597478
1 /* Reduced from haproxy-2.7.1's cfgparse.c. */
3 typedef __SIZE_TYPE__ size_t;
5 extern void*
6 calloc(size_t __nmemb, size_t __size)
7 __attribute__((__nothrow__, __leaf__))
8 __attribute__((__malloc__)) __attribute__((__alloc_size__(1, 2)));
10 struct list
12 struct list* n;
13 struct list* p;
16 struct cfg_postparser
18 struct list list;
19 char* name;
20 int (*func)();
23 extern struct list postparsers;
25 int
26 cfg_register_postparser(char* name, int (*func)())
28 struct cfg_postparser* cp;
30 cp = (struct cfg_postparser *) calloc(1, sizeof(*cp));
31 if (!cp) {
32 /* [...snip...] */
33 return 0;
35 cp->name = name;
36 cp->func = func;
39 (&cp->list)->p = (&postparsers)->p;
40 (&cp->list)->p->n = (&postparsers)->p = (&cp->list);
41 (&cp->list)->n = (&postparsers);
42 (&cp->list);
43 });
45 return 1; /* { dg-bogus "leak of 'cp'" } */