Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==57382==ERROR: AddressSanitizer: attempting double-free on 0x616000000680 in thread T0: #0 0x4dc7a0 (/out/package/ex4+0x4dc7a0) #1 0x7ffa5035236d (/lib/x86_64-linux-gnu/libc.so.6+0x7e36d) #2 0x4db23d (/out/package/ex4+0x4db23d) #3 0x518827 (/out/package/ex4+0x518827) #4 0x514fe7 (/out/package/ex4+0x514fe7) #5 0x7ffa502f5b96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #6 0x41cab9 (/out/package/ex4+0x41cab9) 0x616000000680 is located 0 bytes inside of 552-byte region [0x616000000680,0x6160000008a8) freed by thread T0 here: #0 0x4dc7a0 (/out/package/ex4+0x4dc7a0) #1 0x7ffa5035236d (/lib/x86_64-linux-gnu/libc.so.6+0x7e36d) previously allocated by thread T0 here: #0 0x4dc970 (/out/package/ex4+0x4dc970) #1 0x7ffa50352eb9 (/lib/x86_64-linux-gnu/libc.so.6+0x7eeb9) #2 0x515402 (/out/package/ex4+0x515402) #3 0x514fe7 (/out/package/ex4+0x514fe7) #4 0x7ffa502f5b96 (/lib/x86_64-linux-gnu
Hints
Your answer may be identical to the JOJ answer in the first several lines.
However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
JOJ Answer
STDOUT START -22 -56 -5 109 83 -99 -147 -22 40 41 64 -152 108 -28 -43 88 -605 2545 -836 12923 -6513 5984 -2097 16071 -2020 -786 -4401 -10905 -3120 514 4131 3499 1242 -6117 -8779 7534 2603 -4400 11054 -10322 176 1501 -925 2712 -4122 5306 -6368 8560 STDOUT END