diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2016-01-04 23:52:20 +0100 |
---|---|---|
committer | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2016-01-05 22:30:32 +0100 |
commit | fa74cdc60d19798c951dcc242ca7273e6483f2b3 (patch) | |
tree | a3a89d051b9ea2a945ac4c48243362cd6421ef00 /libavcodec | |
parent | c3c22bee6362737cf290929b7f31df9fb88da983 (diff) | |
download | ffmpeg-fa74cdc60d19798c951dcc242ca7273e6483f2b3.tar.gz |
parser: add av_assert1 to make sure the codec matches
Otherwise this can have some surprising effects (crashes), so let's
better not allow it.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/parser.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 2809158c35..d25d261acd 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -141,6 +141,13 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, int index, i; uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE]; + /* Parsers only work for the specified codec ids. */ + av_assert1(avctx->codec_id == s->parser->codec_ids[0] || + avctx->codec_id == s->parser->codec_ids[1] || + avctx->codec_id == s->parser->codec_ids[2] || + avctx->codec_id == s->parser->codec_ids[3] || + avctx->codec_id == s->parser->codec_ids[4]); + if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { s->next_frame_offset = s->cur_offset = pos; |