When allocating a new stream failed, the contents of an AVBPrint as well as a subtitle queue would leak. This commit fixes this.
It also slightly simplifies the cleanup process by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- This patch and the other patches that involve subtitle queues should only be applied after https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/258790.html libavformat/mpsubdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c index 82c73457ea..8bb1e97b8d 100644 --- a/libavformat/mpsubdec.c +++ b/libavformat/mpsubdec.c @@ -154,8 +154,10 @@ static int mpsub_read_header(AVFormatContext *s) } st = avformat_new_stream(s, NULL); - if (!st) - return AVERROR(ENOMEM); + if (!st) { + res = AVERROR(ENOMEM); + goto end; + } avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num); st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_id = AV_CODEC_ID_TEXT; @@ -163,9 +165,6 @@ static int mpsub_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &mpsub->q); end: - if (res < 0) - ff_subtitles_queue_clean(&mpsub->q); - av_bprint_finalize(&buf, NULL); return res; } @@ -201,4 +200,5 @@ AVInputFormat ff_mpsub_demuxer = { .read_seek2 = mpsub_read_seek, .read_close = mpsub_read_close, .extensions = "sub", + .flags_internal = FF_INPUTFORMAT_HEADER_CLEANUP, }; -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".