Bug path

test
‘test’: events 1-2
18void test (void)
^~~~
|
(1) entry to ‘test’
19{
20 void *ptr = calls_malloc ();
~~~~~~~~~~~~~~~
|
(2) calling ‘calls_malloc’ from ‘test’
calls_malloc
‘calls_malloc’: events 3-4
4calls_malloc (void)
^~~~~~~~~~~~
|
(3) entry to ‘calls_malloc’
5{
6 void *result = malloc (1024);
~~~~~~~~~~~~~
|
(4) allocated here
‘test’: events 5-6
20 void *ptr = calls_malloc ();
^~~~~~~~~~~~~~~
|
(5) returning to ‘test’ from ‘calls_malloc’
21 calls_free (ptr);
~~~~~~~~~~~~~~~~
|
(6) calling ‘calls_free’ from ‘test’
calls_free
‘calls_free’: events 7-8
11calls_free (void *victim)
^~~~~~~~~~
|
(7) entry to ‘calls_free’
12{
13 free (victim); /* { dg-warning "double-'free' of 'victim'" } */
~~~~~~~~~~~~~
|
(8) first ‘free’ here
‘test’: events 9-10
21 calls_free (ptr);
^~~~~~~~~~~~~~~~
|
(9) returning to ‘test’ from ‘calls_free’
22 calls_free (ptr); /* BUG: double-'free'. */
~~~~~~~~~~~~~~~~
|
(10) passing freed pointer ‘ptr’ in call to ‘calls_free’ from ‘test’
calls_free
‘calls_free’: events 11-12
11calls_free (void *victim)
^~~~~~~~~~
|
(11) entry to ‘calls_free’
12{
13 free (victim); /* { dg-warning "double-'free' of 'victim'" } */
~~~~~~~~~~~~~
|
(12) second ‘free’ here; first ‘free’ was at (8)