diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-28 10:54:35 +0100 |
---|---|---|
committer | Sean McGovern <gseanmcg@gmail.com> | 2014-04-14 16:55:39 -0400 |
commit | d8e89a37267f276afd404bd062e5112a336d1a36 (patch) | |
tree | ac26f25be8d7db095116855028cfae21f0b33ced | |
parent | 7e8d27c8510a024e6d66d2e1116bb8692d9cb98a (diff) | |
download | ffmpeg-d8e89a37267f276afd404bd062e5112a336d1a36.tar.gz |
h264: reset data partitioning at the beginning of each decode call
Prevents using GetBitContexts with data from previous calls.
Fixes access to freed memory.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
-rw-r--r-- | libavcodec/h264.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 7904e64576..702a272d98 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4059,6 +4059,13 @@ again: } break; case NAL_DPA: + if (s->flags2 & CODEC_FLAG2_CHUNKS) { + av_log(h->s.avctx, AV_LOG_ERROR, + "Decoding in chunks is not supported for " + "partitioned slices.\n"); + return AVERROR(ENOSYS); + } + init_get_bits(&hx->s.gb, ptr, bit_length); hx->intra_gb_ptr = hx->inter_gb_ptr = NULL; @@ -4191,6 +4198,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, s->flags = avctx->flags; s->flags2 = avctx->flags2; + /* reset data partitioning here, to ensure GetBitContexts from previous + * packets do not get used. */ + s->data_partitioning = 0; /* end of stream, output what is still in the buffers */ out: |