Function
test_30
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
358
Column
1
| 358 | | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ |
| | | ^ |
|
test_30
|
test_30: events 1-2
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c:357:30:
| 357 | | tmp.m_ptr = (struct link *)malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 358 | | } /* { dg-warning "leak of 'tmp.m_ptr'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘tmp.m_ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_1
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
12
Column
3
| 12 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_1
|
test_1: events 1-3
| 10 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 11 | | free (ptr); |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) first ‘free’ here
|
| 12 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ second ‘free’ here; first ‘free’ was at (2)
|
|
|
Function
test_2
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
18
Column
3
| 18 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_2
|
test_2: events 1-2
| 17 | | free (ptr); |
| | | ^~~~~~~~~~ |
| | | | |
| | | (1) first ‘free’ here
|
| 18 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ second ‘free’ here; first ‘free’ was at (1)
|
|
|
Function
test_2a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
24
Column
3
| 24 | | __builtin_free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~ |
|
test_2a
|
test_2a: events 1-2
| 23 | | __builtin_free (ptr); |
| | | ^~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) first ‘free’ here
|
| 24 | | __builtin_free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ second ‘free’ here; first ‘free’ was at (1)
|
|
|
Function
test_3
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
30
Column
8
| 30 | | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~^~~~ |
|
test_3
|
test_3: events 1-2
| 29 | | int *ptr = (int *)malloc (sizeof (int)); |
| | | ^~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 30 | | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ could be NULL: unchecked value from (1)
|
|
|
Function
test_3a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
37
Column
8
| 37 | | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~^~~~ |
|
test_3a
|
test_3a: events 1-2
| 36 | | int *ptr = (int *)__builtin_malloc (sizeof (int)); |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 37 | | *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ could be NULL: unchecked value from (1)
|
|
|
Function
test_4
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
47
Column
10
| 47 | | *ptr = 43; /* { dg-warning "dereference of NULL 'ptr' \\\[CWE-476\\\]" } */ |
| | | ~~~~~^~~~ |
|
test_4
|
test_4: events 1-5
| 43 | | int *ptr = (int *)malloc (sizeof (int)); |
| | | ^~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 44 | | if (ptr) |
| | | ~ |
| | | | |
| | | (2) assuming ‘ptr’ is NULL
|
| | | (3) following ‘false’ branch (when ‘ptr’ is NULL)...
─>─┐ |
| | | │ |
| [...] | |
| | | │ |
| | ┌ | ─────────────────────────────────────────────────────────────┘ |
| 47 | │ | *ptr = 43; /* { dg-warning "dereference of NULL 'ptr' \\\[CWE-476\\\]" } */ |
| | │ | ~~~~~~~~~ |
| | │ | | |
| | └ | ────────>(4) ...to here
|
| | | (5) ⚠️ dereference of NULL ‘ptr’
|
|
|
Function
test_5
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
54
Column
10
| 54 | | return *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */ |
| | | ^~~~ |
|
test_5
|
test_5: events 1-2
| 53 | | free (ptr); |
| | | ^~~~~~~~~~ |
| | | | |
| | | (1) freed here
|
| 54 | | return *ptr; /* { dg-warning "use after 'free' of 'ptr'" } */ |
| | | ~~~~ |
| | | | |
| | | (2) ⚠️ use after ‘free’ of ‘ptr’; freed at (1)
|
|
|
Function
test_6
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
62
Column
3
| 62 | | free (q); /* { dg-warning "double-'free' of 'q'" } */ |
| | | ^~~~~~~~ |
|
test_6
|
test_6: events 1-2
| 61 | | free (ptr); |
| | | ^~~~~~~~~~ |
| | | | |
| | | (1) first ‘free’ here
|
| 62 | | free (q); /* { dg-warning "double-'free' of 'q'" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (2) ⚠️ second ‘free’ here; first ‘free’ was at (1)
|
|
|
Function
test_9
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
93
Column
5
| 93 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_9
|
test_9: events 1-4
| 89 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 92 | | for (i = 0; i < 1024; i++) |
| | | ~~~~~~~~ |
| | | | |
| | | (2) following ‘true’ branch (when ‘i <= 1023’)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ─────────────────────────────────────────────────────────────────────┘ |
| 93 | │ | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | │ | ~~~~~~~~~~ |
| | │ | | |
| | └ | ───>(3) ...to here
|
| | | (4) first ‘free’ here
|
|
|
test_9: events 5-7
| 92 | | for (i = 0; i < 1024; i++) |
| | | ~~^~~~~~ |
| | | | |
| | | (5) following ‘true’ branch (when ‘i <= 1023’)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ─────────────────────────────────────────────────────────────────────┘ |
| 93 | │ | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | │ | ~~~~~~~~~~ |
| | │ | | |
| | └ | ───>(6) ...to here
|
| | | (7) ⚠️ second ‘free’ here; first ‘free’ was at (4)
|
|
|
Function
test_10
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
105
Column
3
| 105 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_10
|
test_10: events 1-5
| 98 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 101 | | for (i = 0; i < 1024; i++) |
| | | ~~~~~~~~ |
| | | | |
| | | (2) following ‘true’ branch (when ‘i <= 1023’)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ─────────────────────────────────────────────────────────────────────┘ |
| 102 | │ | foo (); |
| | │ | ~~~~~~ |
| | │ | | |
| | └ | ───>(3) ...to here
|
| 103 | | |
| 104 | | free (ptr); |
| | | ~~~~~~~~~~ |
| | | | |
| | | (4) first ‘free’ here
|
| 105 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (5) ⚠️ second ‘free’ here; first ‘free’ was at (4)
|
|
|
Function
test_11
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
116
Column
3
| 116 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_11
|
test_11: events 1-3
| 110 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 115 | | free (ptr); |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) first ‘free’ here
|
| 116 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ second ‘free’ here; first ‘free’ was at (2)
|
|
|
Function
test_12
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
125
Column
7
| 125 | | free (ptr); /* { dg-warning "infinite loop" } */ |
| | | ^~~~~~~~~~ |
|
test_12
|
test_12: events 1-2
| 125 | | free (ptr); /* { dg-warning "infinite loop" } */ |
| | | ^~~~~~~~~~ |
| | | | |
| | | (1) ⚠️ infinite loop here
|
| 126 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) looping back...
─>─┐ |
| | | │ |
|
|
test_12: event 3
| | | │ |
| | ┌ | ─────────────────────────────┘ |
| 125 | │ | free (ptr); /* { dg-warning "infinite loop" } */ |
| | │ | ^~~~~~~~~~ |
| | │ | | |
| | └ | ─────>(3) ...to here
|
|
|
Function
test_12
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
126
Column
7
| 126 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_12
|
test_12: events 1-3
| 121 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 125 | | free (ptr); /* { dg-warning "infinite loop" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) first ‘free’ here
|
| 126 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ second ‘free’ here; first ‘free’ was at (2)
|
|
|
Function
test_13
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
139
Column
7
| 139 | | return; /* { dg-warning "leak of 'p'" } */ |
| | | ^~~~~~ |
|
test_13
|
test_13: events 1-4
| 132 | | void *p = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 136 | | if (!q) |
| | | ~ |
| | | | |
| | | (2) following ‘true’ branch (when ‘q’ is NULL)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ──────────────────────────────────────────────────────────┘ |
| 137 | │ | { |
| 138 | │ | free (q); |
| | │ | ~~~~~~~~ |
| | │ | | |
| | └ | ─────>(3) ...to here
|
| 139 | | return; /* { dg-warning "leak of 'p'" } */ |
| | | ~~~~~~ |
| | | | |
| | | (4) ⚠️ ‘p’ leaks here; was allocated at (1)
|
|
|
Function
test_14
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
164
Column
3
| 164 | | free (p); /* { dg-warning "double-'free' of 'p'" } */ |
| | | ^~~~~~~~ |
|
test_14
|
test_14: events 1-8
| 149 | | p = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 150 | | if (!p) |
| | | ~ |
| | | | |
| | | (2) assuming ‘p’ is non-NULL
|
| | | (3) following ‘false’ branch (when ‘p’ is non-NULL)...
─>─┐ |
| | | │ |
| [...] | |
| | | │ |
| | ┌ | ───────────────────────────────────────────────────────────────┘ |
| 153 | │ | q = malloc (1024); |
| | │ | ~~~~~~~~~~~~~ |
| | │ | | |
| | └ | ─────>(4) ...to here
|
| 154 | | if (!q) |
| | | ~ |
| | | | |
| | | (5) following ‘true’ branch (when ‘q’ is NULL)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ──────────────────────────────────────────────────────────┘ |
| 155 | │ | { |
| 156 | │ | free (p); |
| | │ | ~~~~~~~~ |
| | │ | | |
| | └ | ─────>(6) ...to here
|
| | | (7) first ‘free’ here
|
| [...] | |
| 164 | | free (p); /* { dg-warning "double-'free' of 'p'" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (8) ⚠️ second ‘free’ here; first ‘free’ was at (7)
|
|
|
Function
test_16
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
205
Column
3
| 205 | | free (q); /* { dg-warning "use of uninitialized value 'q'" } */ |
| | | ^~~~~~~~ |
|
test_16
|
test_16: events 1-5
| 190 | | void *p, *q; /* { dg-message "region created on stack here" } */ |
| | | ^ |
| | | | |
| | | (1) region created on stack here |
| | | (2) capacity: 8 bytes |
| [...] | |
| 193 | | if (!p) |
| | | ~ |
| | | | |
| | | (3) following ‘true’ branch (when ‘p’ is NULL)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ──────────────────────────────────────────────────────────┘ |
| 194 | │ | goto fail; |
| | │ | ~~~~ |
| | │ | | |
| | └ | ───>(4) ...to here
|
| [...] | |
| 205 | | free (q); /* { dg-warning "use of uninitialized value 'q'" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (5) ⚠️ use of uninitialized value ‘q’ here
|
|
|
Function
test_17
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
212
Column
1
| 212 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ^ |
|
test_17
|
test_17: events 1-2
| 211 | | void *ptr = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 212 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_18
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
217
Column
7
| 217 | | ptr = NULL; /* { dg-warning "leak of 'ptr'" } */ |
| | | ^ |
|
test_18
|
test_18: event 1
| 216 | | void *ptr = malloc (64); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
|
|
test_18: event 2
| 217 | | ptr = NULL; /* { dg-warning "leak of 'ptr'" } */ |
| | | ^ |
| | | | |
| | | (2) ⚠️ ‘ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_22
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
253
Column
3
| 253 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ^~~~~~~~~~ |
|
test_22
|
test_22: events 1-5
| 246 | | void *ptr = malloc (1024); |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 249 | | for (i = 5; i < 10; i++) |
| | | ~~~~~~ |
| | | | |
| | | (2) following ‘true’ branch (when ‘i <= 9’)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ──────────────────────────────────────────────────────────────────┘ |
| 250 | │ | foo (); |
| | │ | ~~~~~~ |
| | │ | | |
| | └ | ───>(3) ...to here
|
| 251 | | |
| 252 | | free (ptr); |
| | | ~~~~~~~~~~ |
| | | | |
| | | (4) first ‘free’ here
|
| 253 | | free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (5) ⚠️ second ‘free’ here; first ‘free’ was at (4)
|
|
|
Function
test_23
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
259
Column
10
| 259 | | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~^~~~ |
|
test_23
|
test_23: events 1-2
| 258 | | int *ptr = (int *)calloc (n, sizeof (int)); |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 259 | | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ could be NULL: unchecked value from (1)
|
|
|
Function
test_23a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
266
Column
10
| 266 | | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~^~~~ |
|
test_23a
|
test_23a: events 1-2
| 265 | | int *ptr = (int *)__builtin_calloc (n, sizeof (int)); |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 266 | | ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ could be NULL: unchecked value from (1)
|
|
|
Function
test_24
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
273
Column
3
| 273 | | free (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~ |
|
test_24
|
test_24: events 1-3
| 272 | | void *ptr = __builtin_alloca (sizeof (int)); /* { dg-message "region created on stack here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) region created on stack here |
| | | (2) capacity: 4 bytes |
| 273 | | free (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ call to ‘free’ here
|
|
|
Function
test_25
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
280
Column
3
| 280 | | free (p); /* { dg-warning "'free' of 'p' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~ |
|
test_25
|
test_25: events 1-3
| 278 | | char tmp[100]; /* { dg-message "region created on stack here" } */ |
| | | ^~~ |
| | | | |
| | | (1) region created on stack here |
| | | (2) capacity: 100 bytes |
| 279 | | void *p = tmp; |
| 280 | | free (p); /* { dg-warning "'free' of 'p' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (3) ⚠️ call to ‘free’ here
|
|
|
Function
test_26
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
289
Column
3
| 289 | | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~ |
|
event 1
| 284 | | char global_buffer[100]; /* { dg-message "region created here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) region created here |
|
|
test_26
|
test_26: event 2
| 289 | | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~ |
| | | | |
| | | (2) ⚠️ call to ‘free’ here
|
|
|
Function
test_27
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
301
Column
8
| 301 | | p->x = 0.f; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" } */ |
| | | ~~~~~^~~~~ |
|
test_27
|
test_27: events 1-2
| 300 | | struct coord *p = (struct coord *) malloc (sizeof (struct coord)); /* { dg-message "this call could return NULL" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 301 | | p->x = 0.f; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘p’ could be NULL: unchecked value from (1)
|
|
|
Function
test_28
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
312
Column
8
| 312 | | p->x = 0.f; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~~~^~~~~ |
|
test_28
|
test_28: events 1-3
| 311 | | struct coord *p = NULL; |
| | | ^ |
| | | | |
| | | (1) ‘p’ is NULL
|
| 312 | | p->x = 0.f; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ dereference of NULL ‘p’
|
| [...] | |
| 317 | | return p; |
| | | ~ |
| | | | |
| | | (2) ‘p’ is NULL
|
|
|
Function
test_31
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
366
Column
1
| 366 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ^ |
|
test_31
|
test_31: events 1-2
| 364 | | void *ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 365 | | tmp.m_ptr = (struct link *)ptr; |
| 366 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_33
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
379
Column
1
| 379 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ^ |
|
test_33
|
test_33: events 1-2
| 377 | | void *ptr = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| 378 | | cant_free (ptr); |
| 379 | | } /* { dg-warning "leak of 'ptr'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_34
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
390
Column
6
| 390 | | *q = 1.0f; /* { dg-warning "use after 'free' of 'q'" } */ |
| | | ~~~^~~~~~ |
|
test_34
|
test_34: events 1-3
| 385 | | if (!p) |
| | | ^ |
| | | | |
| | | (1) following ‘false’ branch (when ‘p’ is non-NULL)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ───────────────────────────────────────────────────────────────┘ |
| 386 | │ | return; |
| 387 | │ | p->x = 0.0f; |
| | │ | ~~~~~~~~~~~ |
| | │ | | |
| | └ | ──────>(2) ...to here
|
| [...] | |
| 390 | | *q = 1.0f; /* { dg-warning "use after 'free' of 'q'" } */ |
| | | ~~~~~~~~~ |
| | | | |
| | | (3) ⚠️ use after ‘free’ of ‘q’ here
|
|
|
Function
test_37a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
415
Column
3
| 415 | | __builtin_memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected \\\[CWE-690\\\]" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
test_37a
|
test_37a: events 1-2
| 414 | | void *ptr = malloc(4096); /* { dg-message "this call could return NULL" } */ |
| | | ^~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 415 | | __builtin_memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected \\\[CWE-690\\\]" } */ |
| | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (2) ⚠️ argument 1 (‘ptr’) from (1) could be NULL where non-null expected
|
|
|
note: argument 1 of ‘__builtin_memset’ must be non-null
File
<built-in>
Function
test_37b
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
426
Column
5
| 426 | | __builtin_memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected \\\[CWE-690\\\]" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
test_37b
|
test_37b: events 1-4
| 422 | | void *q = malloc(4096); /* { dg-message "this call could return NULL" } */ |
| | | ^~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 423 | | if (p) { |
| | | ~ |
| | | | |
| | | (2) following ‘false’ branch (when ‘p’ is NULL)...
─>─┐ |
| | | │ |
| [...] | |
| | | │ |
| | ┌ | ───────────────────────────────────────────────────────────┘ |
| 426 | │ | __builtin_memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected \\\[CWE-690\\\]" } */ |
| | │ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | │ | | |
| | └ | ───>(3) ...to here
|
| | | (4) ⚠️ argument 1 (‘q’) from (1) could be NULL where non-null expected
|
|
|
note: argument 1 of ‘__builtin_memset’ must be non-null
File
<built-in>
Function
test_39
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
451
Column
6
| 451 | | *p = i; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" } */ |
| | | ~~~^~~ |
|
test_39
|
test_39: events 1-2
| 450 | | int *p = (int*)malloc(sizeof(int*)); /* { dg-message "this call could return NULL" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 451 | | *p = i; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" } */ |
| | | ~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘p’ could be NULL: unchecked value from (1)
|
|
|
Function
test_40
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
459
Column
5
| 459 | | i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" "possibly-null" } */ |
| | | ~~^~~~ |
|
test_40
|
test_40: events 1-2
| 458 | | int *p = (int*)malloc(sizeof(int*)); /* { dg-message "region created on heap here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) region created on heap here |
| 459 | | i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" "possibly-null" } */ |
| | | ~~~~~~ |
| | | | |
| | | (2) ⚠️ use of uninitialized value ‘*p’ here
|
|
|
Function
test_40
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
459
Column
5
| 459 | | i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" "possibly-null" } */ |
| | | ~~^~~~ |
|
test_40
|
test_40: events 1-2
| 458 | | int *p = (int*)malloc(sizeof(int*)); /* { dg-message "region created on heap here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) this call could return NULL
|
| 459 | | i = *p; /* { dg-warning "dereference of possibly-NULL 'p' \\\[CWE-690\\\]" "possibly-null" } */ |
| | | ~~~~~~ |
| | | | |
| | | (2) ⚠️ ‘p’ could be NULL: unchecked value from (1)
|
|
|
Function
test_41
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
475
Column
13
| 475 | | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer' \\\[CWE-690\\\]" "possibly-NULL" } */ |
| | | ~~~~~~~~~~^~~~~ |
|
test_41
|
test_41: event 1
| 469 | | if (flag) { |
| | | ^ |
| | | | |
| | | (1) following ‘false’ branch (when ‘flag == 0’)...
─>─┐ |
| | | │ |
|
|
test_41: event 2
| | | │ |
| | ┌ | ───────────────────────────────────────────────────────────┘ |
| 472 | │ | buffer = NULL; |
| | │ | ^ |
| | │ | | |
| | └ | ──────────>(2) ...to here
|
|
|
test_41: events 3-5
| 472 | | buffer = NULL; |
| | | ^ |
| | | | |
| | | (3) ‘buffer’ is NULL
|
| [...] | |
| 475 | | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer' \\\[CWE-690\\\]" "possibly-NULL" } */ |
| | | ~~~~~~~~~~~~~~~ |
| | | | |
| | | (5) ⚠️ dereference of NULL ‘buffer’
|
| [...] | |
| 478 | | return buffer; |
| | | ~~~~~~ |
| | | | |
| | | (4) ‘buffer’ is NULL
|
|
|
Function
test_41
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
475
Column
13
| 475 | | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer' \\\[CWE-690\\\]" "possibly-NULL" } */ |
| | | ~~~~~~~~~~^~~~~ |
|
test_41
|
test_41: events 1-4
| 469 | | if (flag) { |
| | | ^ |
| | | | |
| | | (1) following ‘true’ branch (when ‘flag != 0’)...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ──────────────────────────────────────────────────────────┘ |
| 470 | │ | buffer = (char*)malloc(4096); |
| | │ | ~~~~~~~~~~~~ |
| | │ | | |
| | └ | ───────────────────>(2) ...to here
|
| | | (3) this call could return NULL
|
| [...] | |
| 475 | | buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer' \\\[CWE-690\\\]" "possibly-NULL" } */ |
| | | ~~~~~~~~~~~~~~~ |
| | | | |
| | | (4) ⚠️ ‘buffer’ could be NULL: unchecked value from (3)
|
|
|
Function
test_42a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
486
Column
1
| 486 | | } /* { dg-warning "leak of 'p'" } */ |
| | | ^ |
|
test_42a
|
test_42a: events 1-2
| 483 | | void *p = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 486 | | } /* { dg-warning "leak of 'p'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘p’ leaks here; was allocated at (1)
|
|
|
Function
test_42b
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
496
Column
1
| 496 | | } /* { dg-warning "leak of 'p'" } */ |
| | | ^ |
|
test_42b
|
test_42b: events 1-2
| 493 | | void *p = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
| [...] | |
| 496 | | } /* { dg-warning "leak of 'p'" } */ |
| | | ~ |
| | | | |
| | | (2) ⚠️ ‘p’ leaks here; was allocated at (1)
|
|
|
Function
test_43
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
537
Column
21
| 537 | | global_link.m_ptr = NULL; /* { dg-warning "leak of 'global_link.m_ptr'" } */ |
| | | ^ |
|
test_43
|
test_43: event 1
| 536 | | global_link.m_ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) allocated here
|
|
|
test_43: event 2
| 537 | | global_link.m_ptr = NULL; /* { dg-warning "leak of 'global_link.m_ptr'" } */ |
| | | ^ |
| | | | |
| | | (2) ⚠️ ‘global_link.m_ptr’ leaks here; was allocated at (1)
|
|
|
Function
test_44
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
548
Column
3
| 548 | | free (global_ptr); /* { dg-warning "leak of '<unknown>'" } */ |
| | | ^~~~~~~~~~~~~~~~~ |
|
test_44
|
test_44: events 1-4
| 545 | | if (!global_ptr) |
| | | ^ |
| | | | |
| | | (1) following ‘false’ branch...
─>─┐ |
| | | │ |
| | | │ |
| | ┌ | ────────────────────────────────────────┘ |
| 546 | │ | return; |
| 547 | │ | global_ptr->m_ptr = malloc (sizeof (struct link)); /* { dg-message "allocated here" } */ |
| | │ | ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | │ | | | |
| | │ | | (3) allocated here
|
| | └ | ───────────>(2) ...to here
|
| 548 | | free (global_ptr); /* { dg-warning "leak of '<unknown>'" } */ |
| | | ~~~~~~~~~~~~~~~~~ |
| | | | |
| | | (4) ⚠️ ‘<unknown>’ leaks here; was allocated at (3)
|
|
|
Function
test_48
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
593
Column
6
| 593 | | *p = 1; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~^~~ |
|
test_48
|
test_48: events 1-2
| 592 | | int *p = NULL; /* { dg-message "'p' is NULL" } */ |
| | | ^ |
| | | | |
| | | (1) ‘p’ is NULL
|
| 593 | | *p = 1; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~~~~ |
| | | | |
| | | (2) ⚠️ dereference of NULL ‘p’
|
|
|
Function
test_49
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
605
Column
6
| 605 | | *p = 1; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~^~~ |
|
test_49
|
test_49: events 1-2
| 604 | | p = NULL; /* { dg-message "'p' is NULL" } */ |
| | | ^ |
| | | | |
| | | (1) ‘p’ is NULL
|
| 605 | | *p = 1; /* { dg-warning "dereference of NULL 'p' \\\[CWE-476\\\]" } */ |
| | | ~~~~~~ |
| | | | |
| | | (2) ⚠️ dereference of NULL ‘p’
|
|
|
Function
test_50b
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
617
Column
3
| 617 | | free (test_50a); /* { dg-warning "'free' of '&test_50a' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~ |
|
test_50b
|
test_50b: event 1
| 617 | | free (test_50a); /* { dg-warning "'free' of '&test_50a' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~ |
| | | | |
| | | (1) ⚠️ call to ‘free’ here
|
|
|
Function
test_50c
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
623
Column
3
| 623 | | free (&&my_label); /* { dg-warning "'free' of '&my_label' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~~~ |
|
test_50c
|
test_50c: event 1
| 623 | | free (&&my_label); /* { dg-warning "'free' of '&my_label' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~~~ |
| | | | |
| | | (1) ⚠️ call to ‘free’ here
|
|
|
Function
test_51
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
632
Column
3
| 632 | | free (p); /* { dg-warning "double-'free' of 'p'" } */ |
| | | ^~~~~~~~ |
|
test_51
|
test_51: events 1-3
| 630 | | int result = *p; |
| | | ^~~~~~ |
| | | | |
| | | (1) state of ‘INIT_VAL(p_2(D))’: ‘start’ -> ‘assumed-non-null’ (NULL origin)
|
| 631 | | free (p); /* { dg-message "first 'free' here" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (2) first ‘free’ here
|
| 632 | | free (p); /* { dg-warning "double-'free' of 'p'" } */ |
| | | ~~~~~~~~ |
| | | | |
| | | (3) ⚠️ second ‘free’ here; first ‘free’ was at (2)
|
|
|
Function
test_24
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
273
Column
3
| 273 | | free (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~ |
note: returned from ‘__builtin_alloca’
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
272
Column
15
| 272 | | void *ptr = __builtin_alloca (sizeof (int)); /* { dg-message "region created on stack here" } */ |
| | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Function
test_25
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
280
Column
3
| 280 | | free (p); /* { dg-warning "'free' of 'p' which points to memory on the stack \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~ |
note: declared here
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
278
Column
8
| 278 | | char tmp[100]; /* { dg-message "region created on stack here" } */ |
| | | ^~~ |
Function
test_26
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
289
Column
3
| 289 | | free (p); /* { dg-warning "'free' of 'p' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~ |
note: declared here
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
284
Column
6
| 284 | | char global_buffer[100]; /* { dg-message "region created here" } */ |
| | | ^~~~~~~~~~~~~ |
Function
test_42a
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
484
Column
3
| 484 | | free (p + 64); /* this could well corrupt the heap. */ |
| | | ^~~~~~~~~~~~~ |
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
483
Column
13
| 483 | | void *p = malloc (1024); /* { dg-message "allocated here" } */ |
| | | ^~~~~~~~~~~~~ |
Function
test_50b
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
617
Column
3
| 617 | | free (test_50a); /* { dg-warning "'free' of '&test_50a' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~ |
note: declared here
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
611
Column
6
| 611 | | void test_50a (void) |
| | | ^~~~~~~~ |
Function
test_50c
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
623
Column
3
| 623 | | free (&&my_label); /* { dg-warning "'free' of '&my_label' which points to memory not on the heap \\\[CWE-590\\\]" } */ |
| | | ^~~~~~~~~~~~~~~~~ |
note: declared here
File
../../src/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
Line
622
Column
2