saitoha / libsixel

A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel).
MIT License
2.46k stars 82 forks source link

memory leaks detected in image_buffer_resize at fromsixel.c:293 #117

Closed SuhwanSong closed 4 years ago

SuhwanSong commented 4 years ago

img2sixel 1.8.3

There is a memory leak in image_buffer_resize at fromsixel.c:293 please run following cmd to reproduce it.

img2sixel $PoC

poc ASAN LOG

==17978==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 67108864 byte(s) in 1 object(s) allocated from:
    #0 0x4da230 in __interceptor_malloc (/home/tmp/img2sixel+0x4da230)
    #1 0x7f87fcbbabd1 in image_buffer_resize /home/tmp/libsixel/src/fromsixel.c:293:35

SUMMARY: AddressSanitizer: 67108864 byte(s) leaked in 1 allocation(s).
saitoha commented 4 years ago

This problem is caused by huge repeat count parameter in SIXELs. It seems to be fixed in v1.8.3, with 9c013f2. Thanks!

saitoha commented 4 years ago

I misrecognized. It still occurs in v1.8.4.

saitoha commented 4 years ago

Fixed on v1.8.5. Thanks!