Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8316 closed defect (fixed)

memory leaks in new_output_stream(), ffmpeg_opt.c

Reported by: Suhwan Owned by:
Priority: minor Component: ffmpeg
Version: git-master Keywords: leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
There are memory leaks in nut_write_header()
How to reproduce:

% ffmpeg_g -y -i $PoC -loglevel 0 -psnr -c pcm_s24daud tmp.nut

ffmpeg version N-95464-g7056ddc0e0 Copyright (c) 2000-2019 the FFmpeg developers
built with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
configuration: --cc=clang --cxx=clang++ --ld=clang --enable-debug

Here's Valgrind log

==31440== HEAP SUMMARY:
==31440==     in use at exit: 1,406 bytes in 7 blocks
==31440==   total heap usage: 811 allocs, 804 frees, 2,788,111 bytes allocated
==31440== 
==31440== 54 (16 direct, 38 indirect) bytes in 1 blocks are definitely lost in loss record 5 of 7
==31440==    at 0x9FE3E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31440==    by 0x9FE3F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31440==    by 0x592F079: av_malloc (mem.c:87)
==31440==    by 0x592F079: av_mallocz (mem.c:238)
==31440==    by 0x58EA3CC: av_dict_set (dict.c:89)
==31440==    by 0x45D36E: new_output_stream (ffmpeg_opt.c:1554)
==31440==    by 0x455A25: new_audio_stream (ffmpeg_opt.c:1860)
==31440==    by 0x4426EB: open_output_file (ffmpeg_opt.c:2237)
==31440==    by 0x42DE5E: open_files (ffmpeg_opt.c:3283)
==31440==    by 0x42DC06: ffmpeg_parse_options (ffmpeg_opt.c:3337)
==31440==    by 0x487BB3: main (ffmpeg.c:4862)
==31440== 
==31440== 1,320 (264 direct, 1,056 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 7
==31440==    at 0x9FE3E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31440==    by 0x9FE3F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31440==    by 0x592EC7D: av_malloc (mem.c:87)
==31440==    by 0x1481181: avio_alloc_context (aviobuf.c:140)
==31440==    by 0x1481181: url_open_dyn_buf_internal (aviobuf.c:1419)
==31440==    by 0x18751E9: write_headers (nutenc.c:0)
==31440==    by 0x186AA42: nut_write_header (nutenc.c:762)
==31440==    by 0x17DDC5D: avformat_write_header (mux.c:521)
==31440==    by 0x4AB73F: check_init_output_file (ffmpeg.c:2973)
==31440==    by 0x4A837E: init_output_stream (ffmpeg.c:3631)
==31440==    by 0x4C0005: reap_filters (ffmpeg.c:1442)
==31440==    by 0x48D681: transcode_step (ffmpeg.c:4638)
==31440==    by 0x48D681: transcode (ffmpeg.c:4682)
==31440==    by 0x487DC3: main (ffmpeg.c:4884)
==31440== 
==31440== LEAK SUMMARY:
==31440==    definitely lost: 280 bytes in 2 blocks
==31440==    indirectly lost: 1,094 bytes in 4 blocks
==31440==      possibly lost: 0 bytes in 0 blocks
==31440==    still reachable: 32 bytes in 1 blocks
==31440==         suppressed: 0 bytes in 0 blocks
==31440== Reachable blocks (those to which a pointer was found) are not shown.
==31440== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==31440== 
==31440== For counts of detected and suppressed errors, rerun with: -v
==31440== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Please confirm.
Thanks

Attachments (1)

PoC.wav (125.0 KB ) - added by Suhwan 5 years ago.
poc

Download all attachments as: .zip

Change History (4)

by Suhwan, 5 years ago

Attachment: PoC.wav added

poc

comment:1 by James, 5 years ago

Component: undeterminedffmpeg
Status: newopen
Summary: memory leaks in nut_write_header()memory leaks in new_output_stream(), ffmpeg_opt.c

comment:2 by Carl Eugen Hoyos, 5 years ago

Keywords: leak added
Priority: importantminor

comment:3 by mkver, 5 years ago

Resolution: fixed
Status: openclosed
Last edited 5 years ago by mkver (previous) (diff)
Note: See TracTickets for help on using tickets.