Skip to content

Fix memory leak in tiffcrop.c

xiaoxiaoafeifei requested to merge xiaoxiaoafeifei/libtiff:master into master


I found memory leak in file tools/tiffcrop.c.


==931446==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 35 byte(s) in 1 object(s) allocated from:
    #0 0x495ded in malloc (/usr/local/bin/tiffcrop+0x495ded)
    #1 0x4da427 in limitMalloc /root/gitlab/libtiff/tools/tiffcrop.c:709:12
    #2 0x4da427 in loadImage /root/gitlab/libtiff/tools/tiffcrop.c:7113:26
    #3 0x4cb586 in main /root/gitlab/libtiff/tools/tiffcrop.c:2782:17
    #4 0x7f9d21e48082 in __libc_start_main (/lib/x86_64-linux-gnu/

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

Steps to reproduce:

  • CC=afl-clang-fast CXX=afl-clang-fast++ CFLAGS="-g -O0 -fsanitize=address,leak -fno-omit-frame-pointer" CXXFLAGS="-g -O0 -fsanitize=address,leak -fno-omit-frame-pointer" ./configure --disable-shared
  • make & make install
  • /usr/local/bin/tiffcrop poc /tmp/foo

poc: poc

This modification fixes the problem

Edited by xiaoxiaoafeifei

Merge request reports