[FFmpeg-devel] [PATCH] parser: error out if the codec doesn't match
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Tue Jan 5 00:44:40 CET 2016
Otherwise this can have some surprising effects (crashes), so let's
better not allow it.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
libavcodec/parser.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 2809158..1f38edb 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -141,6 +141,17 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
int index, i;
uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
+ if (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]) {
+ av_log(avctx, AV_LOG_ERROR,
+ "The parser doesn't match the codec %s.\n",
+ avcodec_get_name(avctx->codec_id));
+ return buf_size;
+ }
+
if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
s->next_frame_offset =
s->cur_offset = pos;
--
2.6.4
More information about the ffmpeg-devel
mailing list