leak of ‘<unknown> [-Wanalyzer-malloc-leak]
20 free(arr); /* { dg-bogus "leak" "" { xfail *-*-* } } */
^~~~~~~~~
test
test: events 1-5
12 if ((arr = (struct foo **)malloc(n * sizeof(struct foo *))) == NULL)
^
|
(1) following ‘false’ branch (when ‘arr’ is non-NULL)... ─>─┐
[...]
─────────────────────────────────────────────────────────────────┘
15 for (i = 0; i < n; i++) {
~~~~~ ~~~~~
| |
| (3) following ‘true’ branch (when ‘i < n’)... ─>─┐
────────>(2) ...to here
─────────────────────────────────────────────────────────────────┘
16 if ((arr[i] = (struct foo *)malloc(sizeof(struct foo))) == NULL) {
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
───────────>(4) ...to here (5) allocated here
test: events 6-7
16 if ((arr[i] = (struct foo *)malloc(sizeof(struct foo))) == NULL) {
^
|
(6) assuming ‘<unknown>’ is non-NULL
(7) following ‘false’ branch... ─>─┐
test: event 8
──────────────────────────────────────────┘
15 for (i = 0; i < n; i++) {
~^~
|
─────────────────────>(8) ...to here
test: events 9-10
15 for (i = 0; i < n; i++) {
~~^~~
|
(9) following ‘true’ branch (when ‘i < n’)... ─>─┐
─────────────────────────────────────────────────────────────────┘
16 if ((arr[i] = (struct foo *)malloc(sizeof(struct foo))) == NULL) {
~
|
───────────>(10) ...to here
test: events 11-15
16 if ((arr[i] = (struct foo *)malloc(sizeof(struct foo))) == NULL) {
^
|
(11) following ‘true’ branch... ─>─┐
──────────────────────────────────────────┘
17 for (; i >= 0; i--) {
~~~ ~~~~~~
| |
| (13) following ‘true’ branch (when ‘i >= 0’)... ─>─┐
─────>(12) ...to here
──────────────────────────────────────────────────────────────────┘
18 free(arr[i]); /* { dg-bogus "double-'free'" } */
~
|
───────────────>(14) ...to here
19 }
20 free(arr); /* { dg-bogus "leak" "" { xfail *-*-* } } */
~~~~~~~~~
|
(15) ⚠️ ‘<unknown>’ leaks here; was allocated at (5)