demux_mkv: fix av_parser_codec leak

This commit is contained in:
Kacper Michajłow 2024-08-21 15:52:50 +02:00
parent e3a9ce22f9
commit b6f0599bfd
1 changed files with 5 additions and 1 deletions

View File

@ -2756,9 +2756,13 @@ static void mkv_parse_and_add_packet(demuxer_t *demuxer, mkv_track_t *track,
if (track->parse && !track->av_parser) { if (track->parse && !track->av_parser) {
int id = mp_codec_to_av_codec_id(track->stream->codec->codec); int id = mp_codec_to_av_codec_id(track->stream->codec->codec);
const AVCodec *codec = avcodec_find_decoder(id); const AVCodec *codec = avcodec_find_decoder(id);
track->av_parser = av_parser_init(id); assert(!track->av_parser_codec);
if (codec) if (codec)
track->av_parser_codec = avcodec_alloc_context3(codec); track->av_parser_codec = avcodec_alloc_context3(codec);
if (track->av_parser_codec)
track->av_parser = av_parser_init(id);
if (!track->av_parser)
avcodec_free_context(&track->av_parser_codec);
} }
if (!track->parse || !track->av_parser || !track->av_parser_codec) { if (!track->parse || !track->av_parser || !track->av_parser_codec) {