(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
leak-pr109059-2.c
       1  /* Reduced from haproxy-2.7.1's cfgparse.c.  */
       2  
       3  typedef __SIZE_TYPE__ size_t;
       4  
       5  extern void*
       6  calloc(size_t __nmemb, size_t __size)
       7    __attribute__((__nothrow__, __leaf__))
       8    __attribute__((__malloc__)) __attribute__((__alloc_size__(1, 2)));
       9  
      10  struct list
      11  {
      12    struct list* n;
      13    struct list* p;
      14  };
      15  
      16  struct cfg_postparser
      17  {
      18    struct list list;
      19    char* name;
      20  };
      21  
      22  extern struct list postparsers;
      23  
      24  int
      25  test_1 (char* name)
      26  {
      27    struct cfg_postparser* cp;
      28  
      29    cp = calloc(1, sizeof(*cp));
      30    if (!cp) {
      31      /* [...snip...] */
      32      return 0;
      33    }
      34    cp->name = name;
      35  
      36    (&cp->list)->p = (&postparsers)->p;
      37    (&postparsers)->p = (&cp->list);
      38    (&cp->list)->p->n = (&postparsers)->p;
      39    (&cp->list)->n = (&postparsers);
      40  
      41    return 1; /* { dg-bogus "leak of 'cp'" } */
      42  }