Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==46665==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040000031d0 at pc 0x56139771e6a0 bp 0x7ffde87fa4b0 sp 0x7ffde87fa4a0 READ of size 4 at 0x6040000031d0 thread T0 #0 0x56139771e69f in findBook_test (/out/package/ex6+0x569f) #1 0x56139771d712 in main (/out/package/ex6+0x4712) #2 0x7fc09b106b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #3 0x56139771c6f9 in _start (/out/package/ex6+0x36f9) 0x6040000031d0 is located 0 bytes inside of 40-byte region [0x6040000031d0,0x6040000031f8) freed by thread T0 here: #0 0x7fc09c2d57a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8) #1 0x56139771cb6e in removeBook (/out/package/ex6+0x3b6e) #2 0x56139771d51b in main (/out/package/ex6+0x451b) #3 0x7fc09b106b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) previously allocated by thread T0 here: #0 0x7fc09c2d5b40 in __interceptor_malloc (/usr/lib/x86_
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
Linked-List: 5067->2992->1161->1986->3821->3215->3289->503->2593->3061->3184->2522->4245->3650->1647->5682->854->5094->375->3605->5002->254->5712->846->445->869->2848->2367->300->368->2622->5129->6194->745->3318->2670->2276->3519->2118->5016->1582->2923->4763->2796->4801->5307->5497->91->2168->4093->4->6009->4843->4197->126->569->2480->5945->3419->4676->231->4100->3523->4669->5999->3460->3985->5395->2301->834->169->5656->3499->4710->5186->1404->2135->2359->5450->2007->1731->122->1717->380->5397->3331->1269->3188->3297->1152->1762->4301->5019->3257->1356->3207->5199->1074->2845->3535->1659->2517->2095->2575->4875->2154->128->628->1176->290->1350->924->434->1159->2209->34->117->3474->1043->4381->552->2287->3663->50->5063->2330->2410->1664->5614->327->3488->1132->5890->6141->4495->4246->3026->6038->1326->2299->1904->2239->4915->400->1042->783->1038->1936->2921->4956->2766->502->3424->3380->5888->3399->2916->2082->224->330->2685->3547->2837->1644->5163->4657->4968->726->6182->5286->3584->1504->1197->6179->1409->1