X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fparser.c;h=11c41d6a0a0e20a443d91e040261ecfc87d83b01;hb=270ddc2baf8a4533255e770e8e23b2a7cc399026;hp=0a994a3f30be699d7dfa6e6756f701caeaeb839c;hpb=1b98bfb932ad36667ea7f18e24c54978623f6654;p=ffmpeg diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 0a994a3f30b..11c41d6a0a0 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -179,6 +179,9 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, /* offset of the next frame */ s->next_frame_offset = s->cur_offset + index; s->fetch_timestamp = 1; + } else { + /* Don't return a pointer to dummy_buf. */ + *poutbuf = NULL; } if (index < 0) index = 0; @@ -186,6 +189,7 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, return index; } +#if FF_API_PARSER_CHANGE int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe) @@ -220,7 +224,7 @@ int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, return 0; } - +#endif void av_parser_close(AVCodecParserContext *s) { if (s) { @@ -245,6 +249,9 @@ int ff_combine_frame(ParseContext *pc, int next, for (; pc->overread > 0; pc->overread--) pc->buffer[pc->index++] = pc->buffer[pc->overread_index++]; + if (next > *buf_size) + return AVERROR(EINVAL); + /* flush remaining if EOF */ if (!*buf_size && next == END_NOT_FOUND) next = 0; @@ -292,6 +299,10 @@ int ff_combine_frame(ParseContext *pc, int next, *buf = pc->buffer; } + if (next < -8) { + pc->overread += -8 - next; + next = -8; + } /* store overread bytes */ for (; next < 0; next++) { pc->state = pc->state << 8 | pc->buffer[pc->last_index + next];