aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/pr101983-main.c
blob: a84353be35a46220ee9b4615278d3a2ba9fed07a (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
/* { dg-additional-options "-Wno-analyzer-too-complex -fno-analyzer-call-summaries" } */

#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>

struct list {
	struct list* next;
	void *a;
};

void func(struct list **res)
{
	struct list *cur = NULL;
	do {
		struct list *n = malloc(sizeof(struct list));
		void *a = malloc(1);
		if (n == NULL || a == NULL) {
			if (n != NULL) free(n);
			if (a != NULL) free(a);
			break;
		}

		if (cur == NULL) {
			*res = cur = n;
		} else {
			cur->next = n;
			cur = n;
		}
		n->a = a;
	} while (true);
}

int main()
{
	struct list *res;
	func(&res);
}