marc-q/libwav

AddressSanitizer: memory leaks of malloc() in libwav.c:165

Marsman1996 opened this issue · 0 comments

There is a memory leak error when the wav_gain program tries to read the poc file but failed.
It allocated memory in wav_chunk_read() libwav.c:165, but due to the read failure it directly returns in gain_file() wav_gain.c:23 and misses the memory free process in wav_gain():33.

Test Environment

Ubuntu 18.04, 64bit
libwav (master 5cc8746)

How to trigger

  1. compile the program with AddressSanitizer
  2. run the compiled program $ ./wav_gain $POC /dev/null

POC file

https://github.com/Marsman1996/pocs/raw/master/libwav/poc23-libwav-5cc8746-wav_chunk_read-leak

Details

Asan report

==12327==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 218129505 byte(s) in 1 object(s) allocated from:
    #0 0x4d9ca0 in malloc /mnt/d/ubuntu/llvm/llvm-6.0.0.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:88
    #1 0x512769 in wav_chunk_read /mnt/d/ubuntu/dataset/libwav/libwav/tools/wav_gain/../../libwav.c:165:26

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