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:357 #119

Closed SuhwanSong closed 4 years ago

SuhwanSong commented 4 years ago

img2sixel 1.8.3 (git commit 41f6be4)

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

img2sixel --monochrome $PoC

poc ASAN LOG

==4360==ERROR: LeakSanitizer: detected memory leaks

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

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

I can't reproduce it. Could you tell me your environment information?

$ uname -a
Darwin mbp4 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
$ git checkout 41f6be4
$ CC=gcc-7 CFLAGS="-O0 -g -fsanitize=address,leak -fno-omit-frame-pointer" LDFLAGS="-lasan " LDADD="-static-libasan " ./configure && make install
$ img2sixel --version | head -n9
img2sixel 1.8.3

configured with:
  libcurl: yes
  libpng: yes
  libjpeg: yes
  gdk-pixbuf2: no
  GD: no

$ img2sixel --monochrome -- ~/Downloads/id_000014,sig_06,src_000472+001420,op_splice,rep_16
runtime error: bad input detected
image_buffer_init: given height parameter is too huge.
saitoha commented 4 years ago

Fixed on v1.8.5. Thanks!