libsixel icon indicating copy to clipboard operation
libsixel copied to clipboard

Memory leak has detected in malloc_stub.c:45:20

Open optionGo opened this issue 4 months ago • 4 comments

Hi, we have detected a memory leak in the rpl_malloc of malloc_stub.c

optionGo avatar Sep 02 '25 15:09 optionGo

Besides, we have created a PoC of it and the reproduce step is : ./img2sixel -h 50% -r lanczos3 -w 300px $PoC


=================================================================
==17326==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4500 byte(s) in 1 object(s) allocated from:
    #0 0x498b9d in __interceptor_malloc (/root/option/libsixel/build_asan/bin/img2sixel+0x498b9d)
    #1 0x4cdab7 in rpl_malloc /root/option/libsixel/converters/malloc_stub.c:45:20
    #2 0x4dca67 in sixel_allocator_malloc /root/option/libsixel/src/allocator.c:162:12
    #3 0x4f7136 in sixel_frame_resize /root/option/libsixel/src/frame.c:567:37
    #4 0x4d8b7f in sixel_encoder_do_resize /root/option/libsixel/src/encoder.c:712:18
    #5 0x4d7587 in sixel_encoder_encode_frame /root/option/libsixel/src/encoder.c:1039:18
    #6 0x4d6f30 in load_image_callback /root/option/libsixel/src/encoder.c:1752:12
    #7 0x54217e in load_gif /root/option/libsixel/src/fromgif.c:680:22
    #8 0x501cc6 in load_with_builtin /root/option/libsixel/src/loader.c:948:18
    #9 0x501155 in sixel_helper_load_image_file /root/option/libsixel/src/loader.c:1462:18
    #10 0x4d6c47 in sixel_encoder_encode /root/option/libsixel/src/encoder.c:1816:14
    #11 0x4cd728 in main /root/option/libsixel/converters/img2sixel.c:455:22
    #12 0x732bcc2a9082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)

SUMMARY: AddressSanitizer: 4500 byte(s) leaked in 1 allocation(s).

optionGo avatar Sep 02 '25 15:09 optionGo

@optionGo Thanks for the report. I’ve applied the fix to the develop branch; it will be merged into master at the next release. Also, would you consent to us adding the PoC file you provided to the repository for regression testing?

saitoha avatar Sep 04 '25 13:09 saitoha

Of course! Feel free to add the PoC file to the repository for regression testing. Thank you!

optionGo avatar Sep 08 '25 18:09 optionGo