[FFmpeg-devel] [PATCH] avformat/avformat: also clear packet queues when closing a muxer

Michael Niedermayer michael at niedermayer.cc
Fri Jan 17 23:08:08 EET 2025


On Fri, Jan 17, 2025 at 12:05:41AM -0300, James Almer wrote:
> FFFormatContext.packet_buffer is used in mux.c, and if a muxing process fails at a
> point where packets remained in said queue, they will leak.
> 
> Fixes ticket #11419
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavformat/avformat.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/avformat.c b/libavformat/avformat.c
> index eb9afad837..10aad7bb93 100644
> --- a/libavformat/avformat.c
> +++ b/libavformat/avformat.c
> @@ -192,8 +192,7 @@ void avformat_free_context(AVFormatContext *s)
>      av_packet_free(&si->parse_pkt);
>      av_freep(&s->streams);
>      av_freep(&s->stream_groups);
> -    if (s->iformat)
> -        ff_flush_packet_queue(s);
> +    ff_flush_packet_queue(s);
>      av_freep(&s->url);
>      av_free(s);
>  }

breaks fate here:

rm tests/data/hevc-mp4.mov ; ./configure && make -j32 V=2  tests/data/hevc-mp4.mov
make: *** [tests/fate/hevc.mak:229: tests/data/hevc-mp4.mov] Error 254



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or concluded 
you do not care. Either case is a failure of leadership. - Colin Powell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250117/3e8e93d0/attachment.sig>


More information about the ffmpeg-devel mailing list