[FFmpeg-trac] #7827(undetermined:new): libavformat/libavcodec might leak some memory when muxing a flac stream into a matroska container

FFmpeg trac at avcodec.org
Wed Apr 3 21:21:29 EEST 2019


#7827: libavformat/libavcodec might leak some memory when muxing a flac stream
into a matroska container
-------------------------------------+-------------------------------------
             Reporter:  pbelkner     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 How to reproduce:
 {{{
 Apply the patch provided as attachment to the example program
 "<ffmpeg>/doc/example/muxing.c" and run it with valgrind:
 ~$ valgrind --leak-check=yes muxing ./muxing.mkv
 ==1944== Memcheck, a memory error detector
 ==1944== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
 ==1944== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright
 info
 ==1944== Command: muxing ./muxing.mkv
 ==1944==
 [flac @ 0x4ac4980] encoding as 24 bits-per-sample
 Output #0, matroska, to './muxing.mkv':
     Stream #0:0: Video: mpeg4, yuv420p, 352x288, q=2-31, 400 kb/s, 25 tbn
     Stream #0:1: Audio: flac, 44100 Hz, stereo, s32 (24 bit), 64 kb/s
 pts:0 pts_time:0 dts:0 dts_time:0 duration:0 duration_time:0
 stream_index:0
 pts:0 pts_time:0 dts:0 dts_time:0 duration:104 duration_time:0.104
 stream_index:1

 ...

 pts:9960 pts_time:9.96 dts:9960 dts_time:9.96 duration:0 duration_time:0
 stream_index:0
 pts:10031 pts_time:10.031 dts:10031 dts_time:10.031 duration:0
 duration_time:0 stream_index:1
 ==1944==
 ==1944== HEAP SUMMARY:
 ==1944==     in use at exit: 210 bytes in 5 blocks
 ==1944==   total heap usage: 19,441 allocs, 19,436 frees, 12,505,320 bytes
 allocated
 ==1944==
 ==1944== 100 (12 direct, 88 indirect) bytes in 1 blocks are definitely
 lost in loss record 4 of 5
 ==1944==    at 0x482F584: memalign (vg_replace_malloc.c:857)
 ==1944==    by 0x482F69B: posix_memalign (vg_replace_malloc.c:1020)
 ==1944==    by 0xCA5797: av_malloc (mem.c:87)
 ==1944==    by 0xCA5A7A: av_mallocz (mem.c:238)
 ==1944==    by 0xC92D8A: av_buffer_ref (buffer.c:95)
 ==1944==    by 0x3988D7: av_packet_ref (avpacket.c:625)
 ==1944==    by 0x272202: mkv_write_packet (matroskaenc.c:2537)
 ==1944==    by 0x272202: mkv_write_flush_packet (matroskaenc.c:2561)
 ==1944==    by 0x1DEF25: write_packet (mux.c:747)
 ==1944==    by 0x1DEF25: av_write_trailer (mux.c:1259)
 ==1944==    by 0x1D3465: main (muxing_morphed.c:993)
 ==1944==
 ==1944== 110 (12 direct, 98 indirect) bytes in 1 blocks are definitely
 lost in loss record 5 of 5
 ==1944==    at 0x482D1BC: malloc (vg_replace_malloc.c:298)
 ==1944==    by 0x482F4E0: realloc (vg_replace_malloc.c:785)
 ==1944==    by 0xCA57FB: av_realloc (mem.c:144)
 ==1944==    by 0x39797A: av_packet_add_side_data (avpacket.c:315)
 ==1944==    by 0x397A31: av_packet_new_side_data (avpacket.c:341)
 ==1944==    by 0x3981DD: av_packet_copy_props (avpacket.c:586)
 ==1944==    by 0x3988C0: av_packet_ref (avpacket.c:611)
 ==1944==    by 0x272202: mkv_write_packet (matroskaenc.c:2537)
 ==1944==    by 0x272202: mkv_write_flush_packet (matroskaenc.c:2561)
 ==1944==    by 0x1DEF25: write_packet (mux.c:747)
 ==1944==    by 0x1DEF25: av_write_trailer (mux.c:1259)
 ==1944==    by 0x1D3465: main (muxing_morphed.c:993)
 ==1944==
 ==1944== LEAK SUMMARY:
 ==1944==    definitely lost: 24 bytes in 2 blocks
 ==1944==    indirectly lost: 186 bytes in 3 blocks
 ==1944==      possibly lost: 0 bytes in 0 blocks
 ==1944==    still reachable: 0 bytes in 0 blocks
 ==1944==         suppressed: 0 bytes in 0 blocks
 ==1944==
 ==1944== For counts of detected and suppressed errors, rerun with: -v
 ==1944== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
 ~$

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7827>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list