Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==57385==ERROR: AddressSanitizer: attempting double-free on 0x616000000680 in thread T0: #0 0x4dc7a0 (/out/package/ex4+0x4dc7a0) #1 0x7f4428cec36d (/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 0x7f4428c8fb96 (/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 0x7f4428cec36d (/lib/x86_64-linux-gnu/libc.so.6+0x7e36d) previously allocated by thread T0 here: #0 0x4dc970 (/out/package/ex4+0x4dc970) #1 0x7f4428ceceb9 (/lib/x86_64-linux-gnu/libc.so.6+0x7eeb9) #2 0x515402 (/out/package/ex4+0x515402) #3 0x514fe7 (/out/package/ex4+0x514fe7) #4 0x7f4428c8fb96 (/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 85 -97 112 -69 -65 21 123 57 -102 93 101 -24 75 102 -111 103 94 69 9 108 -50 28 178 165 -9 -62 -52 -67 22 -68 -112 61 150 -113 -109 35 166 -56 22 -44 54 143 -108 53 31 8 -25 121 -66 54 44 106 123 -164 -43 15 -73 120 -38 -46 27 0 147 -85 -38 -57 14 79 -29 -42 -13 -132 -20 118 65 -84 -95 -2 -4 -18 97 55 -18 -3 -74 -61 132 43 85 -65 -162 54 38 145 80 76 -2 -3 -120 29 35 87 72 31 127 -39 16 -165 -72 25 43 8 90 -14 32 44 -103 37 -77 8 -148 157 -46 -88 -19 -33 -148 28 -118 104 132 131 -99 -75 -53 -124 42 -36 65 -85 15 -102 -21 -66 9 64 154 33 -192 -92 3 40 30 -49 -4 -48 -89 108 110 -84 10 134 0 -65 59 -4 -84 119 138 188 -53 58 -17 -25 -11 -67 37 -33 75 -33 23 39 -2 -8 59 -37 106 -31 96 -2 3 29 -97 -7 -2 52 -27 33 -119 -24 -30 21 35 41 107 -16 80 -28 56 -81 -151 85 -8 170 104 -67 -28 146 -25 -116 44 -48 142 32 -104 -20 143 41 28 11 20 -77 -131 66 -105 -51 14 -20 86 96 10 113 -55 20 63 -4 41 -30 -119 107 66 32 52 -14 86 110 -38 74 -88 28 -171 94 16 -16 87 162 -25 -74 98 32 43 56 192 72 -129 85