[FFmpeg-cvslog] parser: add av_assert1 to make sure the codec matches
Andreas Cadhalpun
git at videolan.org
Tue Jan 5 22:39:44 CET 2016
ffmpeg | branch: master | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Mon Jan 4 23:52:20 2016 +0100| [fa74cdc60d19798c951dcc242ca7273e6483f2b3] | committer: Andreas Cadhalpun
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 at niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa74cdc60d19798c951dcc242ca7273e6483f2b3
---
libavcodec/parser.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 2809158..d25d261 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;
More information about the ffmpeg-cvslog
mailing list