../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_1’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:13:3: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 13 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_1’: events 1-3 | | 11 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here | 12 | free (ptr); | | ~~~~~~~~~~ | | | | | (2) first ‘free’ here | 13 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (3) second ‘free’ here; first ‘free’ was at (2) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_2’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:19:3: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 19 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_2’: events 1-2 | | 18 | free (ptr); | | ^~~~~~~~~~ | | | | | (1) first ‘free’ here | 19 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (2) second ‘free’ here; first ‘free’ was at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_3’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:25:8: warning: dereference of possibly-NULL ‘ptr’ [CWE-690] [-Wanalyzer-possible-null-dereference] 25 | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */ | ~~~~~^~~~ ‘test_3’: events 1-2 | | 24 | int *ptr = (int *)malloc (sizeof (int)); | | ^~~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL | 25 | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */ | | ~~~~~~~~~ | | | | | (2) ‘ptr’ could be NULL: unchecked value from (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_4’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:35:10: warning: dereference of NULL ‘ptr’ [CWE-690] [-Wanalyzer-null-dereference] 35 | *ptr = 43; /* { dg-warning "dereference of NULL 'ptr'" } */ | ~~~~~^~~~ ‘test_4’: events 1-5 | | 31 | int *ptr = (int *)malloc (sizeof (int)); | | ^~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 32 | if (ptr) | | ~ | | | | | (2) assuming ‘ptr’ is NULL | | (3) following ‘false’ branch (when ‘ptr’ is NULL)... |...... | 35 | *ptr = 43; /* { dg-warning "dereference of NULL 'ptr'" } */ | | ~~~~~~~~~ | | | | | (4) ...to here | | (5) dereference of NULL ‘ptr’ | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_5’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:42:10: warning: use after ‘free’ of ‘ptr’ [CWE-416] [-Wanalyzer-use-after-free] 42 | return *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */ | ^~~~ ‘test_5’: events 1-2 | | 41 | free (ptr); | | ^~~~~~~~~~ | | | | | (1) freed here | 42 | return *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */ | | ~~~~ | | | | | (2) use after ‘free’ of ‘ptr’; freed at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_6’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:50:3: warning: double-‘free’ of ‘q’ [CWE-415] [-Wanalyzer-double-free] 50 | free (q); /* { dg-warning "double-'free' of 'q'" } */ | ^~~~~~~~ ‘test_6’: events 1-2 | | 48 | q = ptr; | | ~~^~~~~ | | | | | (1) first ‘free’ here | 49 | free (ptr); | 50 | free (q); /* { dg-warning "double-'free' of 'q'" } */ | | ~~~~~~~~ | | | | | (2) second ‘free’ here; first ‘free’ was at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_9’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:81:5: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 81 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_9’: events 1-7 | | 77 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 80 | for (i = 0; i < 1024; i++) | | ~~~ | | | | | (2) following ‘true’ branch (when ‘i <= 1023’)... | | (5) following ‘true’ branch (when ‘i <= 1023’)... | 81 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (3) ...to here | | (4) first ‘free’ here | | (6) ...to here | | (7) second ‘free’ here; first ‘free’ was at (4) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_10’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:93:3: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 93 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_10’: events 1-7 | | 86 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 89 | for (i = 0; i < 1024; i++) | | ~~~ | | | | | (2) following ‘true’ branch (when ‘i <= 1023’)... | | (4) following ‘false’ branch (when ‘i > 1023’)... | 90 | foo (); | | ~~~~~~ | | | | | (3) ...to here | 91 | | 92 | free (ptr); | | ~~~~~~~~~~ | | | | | (5) ...to here | | (6) first ‘free’ here | 93 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (7) second ‘free’ here; first ‘free’ was at (6) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_11’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:104:3: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 104 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_11’: events 1-5 | | 98 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here | 99 | | 100 | while (foo ()) | | ~ | | | | | (2) following ‘false’ branch... |...... | 103 | free (ptr); | | ~~~~~~~~~~ | | | | | (3) ...to here | | (4) first ‘free’ here | 104 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (5) second ‘free’ here; first ‘free’ was at (4) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_12’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:114:7: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 114 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_12’: events 1-3 | | 109 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 113 | free (ptr); | | ~~~~~~~~~~ | | | | | (2) first ‘free’ here | 114 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (3) second ‘free’ here; first ‘free’ was at (2) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_13’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:127:7: warning: leak of ‘p’ [CWE-401] [-Wanalyzer-malloc-leak] 127 | return; /* { dg-warning "leak of 'p'" } */ | ^~~~~~ ‘test_13’: events 1-4 | | 120 | void *p = malloc (1024); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 124 | if (!q) | | ~ | | | | | (2) following ‘true’ branch (when ‘q’ is NULL)... | 125 | { | 126 | free (q); | | ~~~~~~~~ | | | | | (3) ...to here | 127 | return; /* { dg-warning "leak of 'p'" } */ | | ~~~~~~ | | | | | (4) ‘p’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_14’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:152:3: warning: double-‘free’ of ‘p’ [CWE-415] [-Wanalyzer-double-free] 152 | free (p); /* { dg-warning "double-'free' of 'p'" } */ | ^~~~~~~~ ‘test_14’: events 1-8 | | 137 | p = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here | 138 | if (!p) | | ~ | | | | | (2) assuming ‘p’ is non-NULL | | (3) following ‘false’ branch (when ‘p’ is non-NULL)... |...... | 141 | q = malloc (1024); | | ~~~~~~~~~~~~~ | | | | | (4) ...to here | 142 | if (!q) | | ~ | | | | | (5) following ‘true’ branch (when ‘q’ is NULL)... | 143 | { | 144 | free (p); | | ~~~~~~~~ | | | | | (6) ...to here | | (7) first ‘free’ here |...... | 152 | free (p); /* { dg-warning "double-'free' of 'p'" } */ | | ~~~~~~~~ | | | | | (8) second ‘free’ here; first ‘free’ was at (7) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_17’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:201:1: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 201 | } /* { dg-warning "leak of 'ptr'" } */ | ^ ‘test_17’: events 1-2 | | 200 | void *ptr = malloc (1024); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~ | | | | | (1) allocated here | 201 | } /* { dg-warning "leak of 'ptr'" } */ | | ~ | | | | | (2) ‘ptr’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_18’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:206:7: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 206 | ptr = NULL; /* { dg-warning "leak of 'ptr'" } */ | ^ ‘test_18’: event 1 | | 205 | void *ptr = malloc (64); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~ | | | | | (1) allocated here | ‘test_18’: event 2 | | 206 | ptr = NULL; /* { dg-warning "leak of 'ptr'" } */ | | ^ | | | | | (2) ‘ptr’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_22’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:242:3: warning: double-‘free’ of ‘ptr’ [CWE-415] [-Wanalyzer-double-free] 242 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | ^~~~~~~~~~ ‘test_22’: events 1-7 | | 235 | void *ptr = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 238 | for (i = 5; i < 10; i++) | | ~~~ | | | | | (2) following ‘true’ branch (when ‘i <= 9’)... | | (4) following ‘false’ branch (when ‘i > 9’)... | 239 | foo (); | | ~~~~~~ | | | | | (3) ...to here | 240 | | 241 | free (ptr); | | ~~~~~~~~~~ | | | | | (5) ...to here | | (6) first ‘free’ here | 242 | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ | | ~~~~~~~~~~ | | | | | (7) second ‘free’ here; first ‘free’ was at (6) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_23’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:248:10: warning: dereference of possibly-NULL ‘ptr’ [CWE-690] [-Wanalyzer-possible-null-dereference] 248 | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */ | ~~~~~~~^~~~ ‘test_23’: events 1-2 | | 247 | int *ptr = (int *)calloc (n, sizeof (int)); | | ^~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL | 248 | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */ | | ~~~~~~~~~~~ | | | | | (2) ‘ptr’ could be NULL: unchecked value from (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_24’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:255:3: warning: ‘free’ of memory allocated on the stack by ‘alloca’ (‘ptr’) will corrupt the heap [CWE-590] [-Wanalyzer-free-of-non-heap] 255 | free (ptr); /* { dg-warning "'free' of memory allocated on the stack by 'alloca' \\('ptr'\\) will corrupt the heap \\\[CWE-590\\\]" } */ | ^~~~~~~~~~ ‘test_24’: event 1 | | 254 | void *ptr = alloca (sizeof (int)); /* { dg-message "memory is allocated on the stack here" } */ | | ^~~~~~ | | | | | (1) memory is allocated on the stack here | ‘test_24’: event 2 | | 255 | free (ptr); /* { dg-warning "'free' of memory allocated on the stack by 'alloca' \\('ptr'\\) will corrupt the heap \\\[CWE-590\\\]" } */ | | ^~~~~~~~~~ | | | | | (2) call to ‘free’ here | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_25’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:262:3: warning: ‘free’ of ‘p’ which points to memory not on the heap [CWE-590] [-Wanalyzer-free-of-non-heap] 262 | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ | ^~~~~~~~ ‘test_25’: events 1-2 | | 261 | void *p = tmp; /* { dg-message "pointer is from here" } */ | | ^ | | | | | (1) pointer is from here | 262 | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ | | ~~~~~~~~ | | | | | (2) call to ‘free’ here | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_26’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:271:3: warning: ‘free’ of ‘p’ which points to memory not on the heap [CWE-590] [-Wanalyzer-free-of-non-heap] 271 | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ | ^~~~~~~~ ‘test_26’: events 1-2 | | 270 | void *p = global_buffer; /* { dg-message "pointer is from here" } */ | | ^ | | | | | (1) pointer is from here | 271 | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ | | ~~~~~~~~ | | | | | (2) call to ‘free’ here | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_27’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:283:8: warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference] 283 | p->x = 0.f; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | ~~~~~^~~~~ ‘test_27’: events 1-2 | | 282 | struct coord *p = (struct coord *) malloc (sizeof (struct coord)); /* { dg-message "this call could return NULL" } */ | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL | 283 | p->x = 0.f; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | | ~~~~~~~~~~ | | | | | (2) ‘p’ could be NULL: unchecked value from (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_28’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:294:8: warning: dereference of NULL ‘p’ [CWE-690] [-Wanalyzer-null-dereference] 294 | p->x = 0.f; /* { dg-warning "dereference of NULL 'p'" } */ | ~~~~~^~~~~ ‘test_28’: events 1-2 | | 293 | struct coord *p = NULL; | | ^ | | | | | (1) assuming ‘p’ is NULL | 294 | p->x = 0.f; /* { dg-warning "dereference of NULL 'p'" } */ | | ~~~~~~~~~~ | | | | | (2) dereference of NULL ‘p’ | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_30’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:340:1: warning: leak of ‘tmp.m_ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 340 | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ | ^ ‘test_30’: events 1-3 | | 339 | tmp.m_ptr = (struct link *)malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (1) allocated here | | (2) allocated here | 340 | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ | | ~ | | | | | (3) ‘tmp.m_ptr’ leaks here; was allocated at (2) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:340:1: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak] 340 | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ | ^ ‘test_30’: events 1-2 | | 339 | tmp.m_ptr = (struct link *)malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 340 | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ | | ~ | | | | | (2) ‘<unknown>’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_31’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:348:1: warning: leak of ‘tmp.m_ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 348 | } /* { dg-warning "leak of 'ptr'" } */ | ^ ‘test_31’: events 1-3 | | 346 | void *ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 347 | tmp.m_ptr = (struct link *)ptr; | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (2) allocated here | 348 | } /* { dg-warning "leak of 'ptr'" } */ | | ~ | | | | | (3) ‘tmp.m_ptr’ leaks here; was allocated at (2) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:348:1: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 348 | } /* { dg-warning "leak of 'ptr'" } */ | ^ ‘test_31’: events 1-2 | | 346 | void *ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 347 | tmp.m_ptr = (struct link *)ptr; | 348 | } /* { dg-warning "leak of 'ptr'" } */ | | ~ | | | | | (2) ‘ptr’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_33’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:361:1: warning: leak of ‘ptr’ [CWE-401] [-Wanalyzer-malloc-leak] 361 | } /* { dg-warning "leak of 'ptr'" } */ | ^ ‘test_33’: events 1-2 | | 359 | void *ptr = malloc (1024); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~ | | | | | (1) allocated here | 360 | cant_free (ptr); | 361 | } /* { dg-warning "leak of 'ptr'" } */ | | ~ | | | | | (2) ‘ptr’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_34’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:372:6: warning: use after ‘free’ of ‘q’ [CWE-416] [-Wanalyzer-use-after-free] 372 | *q = 1.0f; /* { dg-warning "use after 'free' of 'q'" } */ | ~~~^~~~~~ ‘test_34’: events 1-3 | | 367 | if (!p) | | ^ | | | | | (1) following ‘false’ branch (when ‘p’ is non-NULL)... | 368 | return; | 369 | p->x = 0.0f; | | ~~~~~~~~~~~ | | | | | (2) ...to here |...... | 372 | *q = 1.0f; /* { dg-warning "use after 'free' of 'q'" } */ | | ~~~~~~~~~ | | | | | (3) use after ‘free’ of ‘q’ here | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_37a’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:397:3: warning: use of possibly-NULL ‘ptr’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] 397 | memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected" } */ | ^~~~~~~~~~~~~~~~~~~~ ‘test_37a’: events 1-2 | | 396 | void *ptr = malloc(4096); /* { dg-message "this call could return NULL" } */ | | ^~~~~~~~~~~~ | | | | | (1) this call could return NULL | 397 | memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected" } */ | | ~~~~~~~~~~~~~~~~~~~~ | | | | | (2) argument 1 (‘ptr’) from (1) could be NULL where non-null expected | In file included from ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:2: /usr/include/string.h:62:14: note: argument 1 of ‘memset’ must be non-null 62 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_37b’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:408:5: warning: use of possibly-NULL ‘q’ where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] 408 | memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected" } */ | ^~~~~~~~~~~~~~~~~~ ‘test_37b’: events 1-4 | | 404 | void *q = malloc(4096); /* { dg-message "this call could return NULL" } */ | | ^~~~~~~~~~~~ | | | | | (1) this call could return NULL | 405 | if (p) { | | ~ | | | | | (2) following ‘false’ branch (when ‘p’ is NULL)... |...... | 408 | memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected" } */ | | ~~~~~~~~~~~~~~~~~~ | | | | | (3) ...to here | | (4) argument 1 (‘q’) from (1) could be NULL where non-null expected | In file included from ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:2: /usr/include/string.h:62:14: note: argument 1 of ‘memset’ must be non-null 62 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_39’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:433:6: warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference] 433 | *p = i; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | ~~~^~~ ‘test_39’: events 1-2 | | 432 | int *p = (int*)malloc(sizeof(int*)); /* { dg-message "this call could return NULL" } */ | | ^~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL | 433 | *p = i; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | | ~~~~~~ | | | | | (2) ‘p’ could be NULL: unchecked value from (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_40’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:441:5: warning: dereference of possibly-NULL ‘p’ [CWE-690] [-Wanalyzer-possible-null-dereference] 441 | i = *p; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | ~~^~~~ ‘test_40’: events 1-2 | | 440 | int *p = (int*)malloc(sizeof(int*)); | | ^~~~~~~~~~~~~~~~~~~~ | | | | | (1) this call could return NULL | 441 | i = *p; /* { dg-warning "dereference of possibly-NULL 'p'" } */ | | ~~~~~~ | | | | | (2) ‘p’ could be NULL: unchecked value from (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_41’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:457:13: warning: dereference of NULL ‘buffer’ [CWE-690] [-Wanalyzer-null-dereference] 457 | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer'" } */ | ~~~~~~~~~~^~~~~ ‘test_41’: event 1 | | 451 | if (flag) { | | ^ | | | | | (1) following ‘false’ branch (when ‘flag == 0’)... | ‘test_41’: event 2 | | 454 | buffer = NULL; | | ^ | | | | | (2) ...to here | ‘test_41’: events 3-4 | | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:457:13: warning: dereference of possibly-NULL ‘buffer’ [CWE-690] [-Wanalyzer-possible-null-dereference] 457 | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer'" } */ | ~~~~~~~~~~^~~~~ ‘test_41’: events 1-4 | | 451 | if (flag) { | | ^ | | | | | (1) following ‘true’ branch (when ‘flag != 0’)... | 452 | buffer = (char*)malloc(4096); | | ~~~~~~~~~~~~ | | | | | (2) ...to here | | (3) this call could return NULL |...... | 457 | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer'" } */ | | ~~~~~~~~~~~~~~~ | | | | | (4) ‘buffer’ could be NULL: unchecked value from (3) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_42a’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:468:1: warning: leak of ‘p’ [CWE-401] [-Wanalyzer-malloc-leak] 468 | } /* { dg-warning "leak of 'p'" } */ | ^ ‘test_42a’: events 1-2 | | 465 | void *p = malloc (1024); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 468 | } /* { dg-warning "leak of 'p'" } */ | | ~ | | | | | (2) ‘p’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_42b’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:478:1: warning: leak of ‘p’ [CWE-401] [-Wanalyzer-malloc-leak] 478 | } /* { dg-warning "leak of 'p'" } */ | ^ ‘test_42b’: events 1-2 | | 475 | void *p = malloc (1024); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 478 | } /* { dg-warning "leak of 'p'" } */ | | ~ | | | | | (2) ‘p’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_42c’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:488:1: warning: leak of ‘p’ [CWE-401] [-Wanalyzer-malloc-leak] 488 | } /* { dg-bogus "leak of 'p'" "" { xfail *-*-* } } */ | ^ ‘test_42c’: events 1-2 | | 485 | void *p = malloc (1024); | | ^~~~~~~~~~~~~ | | | | | (1) allocated here |...... | 488 | } /* { dg-bogus "leak of 'p'" "" { xfail *-*-* } } */ | | ~ | | | | | (2) ‘p’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_43’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:513:1: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak] 513 | } /* { dg-warning "leak of '<unknown>'" } */ | ^ ‘test_43’: events 1-2 | | 511 | global_link.m_ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (1) allocated here | 512 | global_link.m_ptr = NULL; | 513 | } /* { dg-warning "leak of '<unknown>'" } */ | | ~ | | | | | (2) ‘<unknown>’ leaks here; was allocated at (1) | ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c: In function ‘test_44’: ../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:525:3: warning: leak of ‘<unknown>’ [CWE-401] [-Wanalyzer-malloc-leak] 525 | free (global_ptr); /* { dg-warning "leak of '<unknown>'" } */ | ^~~~~~~~~~~~~~~~~ ‘test_44’: events 1-4 | | 522 | if (!global_ptr) | | ^ | | | | | (1) following ‘false’ branch... | 523 | return; | 524 | global_ptr->m_ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ | | ~~ | | | | | (2) ...to here | | (3) allocated here | 525 | free (global_ptr); /* { dg-warning "leak of '<unknown>'" } */ | | ~~~~~~~~~~~~~~~~~ | | | | | (4) ‘<unknown>’ leaks here; was allocated at (3) |