diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-28 10:54:35 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2014-05-31 20:05:19 -0400 |
commit | 27ac9585c97d35b809382be5634c8e5f7211243a (patch) | |
tree | d19b7459e11839ca6ff653f9f4a9c73c77e2cea8 | |
parent | 35ba079fbf281a066f3ac1e1271f3caa402dcd74 (diff) | |
download | ffmpeg-27ac9585c97d35b809382be5634c8e5f7211243a.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 1c2f23a8cf..bca9bda675 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4017,6 +4017,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ } 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; @@ -4170,6 +4177,9 @@ static int decode_frame(AVCodecContext *avctx, 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: |