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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jan 17 15:59:37 EET 2025


James Almer:
> 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);
>  }

This is regression since cb80ec0b6cd7f954839427b4c86958d1475f2df4 which
should be mentioned in the commit message.

- Andreas



More information about the ffmpeg-devel mailing list