PR #23082 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23082 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23082.patch
You may look and think `AVFMT_FLAG_CUSTOM_IO` check is enough, but this is not what it seems. This flag means that user provided custom AVIOContext, before creating AVFormatContext and it should not be closed. However nested sub-demuxers may still open an temporary io, and those have to be closed and use correct io_close2 function. You can see 0dcac9c3f0f8f32009098edb704fac4b08bac951 and ef01061225088c4945f5e309bc695ea5beb2a867 where this flag is cleared for nested opens to avoid leaking those. From 384cd537920013cd8c306153d34d4713d85ba6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Tue, 12 May 2026 13:57:09 +0200 Subject: [PATCH] avformat/demux: use correct close function for custom io MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You may look and think `AVFMT_FLAG_CUSTOM_IO` check is enough, but this is not what it seems. This flag means that user provided custom AVIOContext, before creating AVFormatContext and it should not be closed. However nested sub-demuxers may still open an temporary io, and those have to be closed and use correct io_close2 function. You can see 0dcac9c3f0f8f32009098edb704fac4b08bac951 and ef01061225088c4945f5e309bc695ea5beb2a867 where this flag is cleared for nested opens to avoid leaking those. Signed-off-by: Kacper Michajłow <[email protected]> --- libavformat/demux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index a1909237f0..555399720c 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -368,7 +368,7 @@ fail: ff_id3v2_free_extra_meta(&id3v2_extra_meta); av_dict_free(&tmp); if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO)) - avio_closep(&s->pb); + ff_format_io_close(s, &s->pb); avformat_free_context(s); *ps = NULL; return ret; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
