If inserting a packet into a subtitle queue fails, said queue would leak (because jacosub_read_close() which frees the queue was not called automatically when reading the header fails); moreover, an AVBPrint leaks, too. Both these leaks have been fixed, the former by setting the FF_INPUTFORMAT_HEADER_CLEANUP flag.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavformat/jacosubdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 121c86d659..3e30118b8b 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -188,8 +188,10 @@ static int jacosub_read_header(AVFormatContext *s) AVPacket *sub; sub = ff_subtitles_queue_insert(&jacosub->q, line, len, merge_line); - if (!sub) + if (!sub) { + av_bprint_finalize(&header, NULL); return AVERROR(ENOMEM); + } sub->pos = pos; merge_line = len > 1 && !strcmp(&line[len - 2], "\\\n"); continue; @@ -233,7 +235,7 @@ static int jacosub_read_header(AVFormatContext *s) /* general/essential directives in the extradata */ ret = ff_bprint_to_codecpar_extradata(st->codecpar, &header); if (ret < 0) - goto fail; + return ret; /* SHIFT and TIMERES affect the whole script so packet timing can only be * done in a second pass */ @@ -244,9 +246,6 @@ static int jacosub_read_header(AVFormatContext *s) ff_subtitles_queue_finalize(s, &jacosub->q); return 0; -fail: - jacosub_read_close(s); - return ret; } static int jacosub_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -272,4 +271,5 @@ AVInputFormat ff_jacosub_demuxer = { .read_packet = jacosub_read_packet, .read_seek2 = jacosub_read_seek, .read_close = jacosub_read_close, + .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".