[FFmpeg-devel] [PATCH] avformat/utils: unref packet on AVInputFormat.read_packet() failure
James Almer
jamrial at gmail.com
Thu Sep 19 06:09:34 EEST 2019
Demuxers may have allocated a packet before encountering an error and aborting.
Fixes ticket #8150
Signed-off-by: James Almer <jamrial at gmail.com>
---
It may also fix other tickets as well, since i recall seeing other reports about
leaks in ff_read_packet() on malformed input in the past, but i can't remember
which.
libavformat/utils.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3983a3f4ce..215cbe6df8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -854,6 +854,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
av_init_packet(pkt);
ret = s->iformat->read_packet(s, pkt);
if (ret < 0) {
+ av_packet_unref(pkt);
+
/* Some demuxers return FFERROR_REDO when they consume
data and discard it (ignored streams, junk, extradata).
We must re-call the demuxer to get the real packet. */
--
2.22.0
More information about the ffmpeg-devel
mailing list