aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-28 10:54:35 +0100
committerAnton Khirnov <anton@khirnov.net>2014-02-04 11:26:17 +0100
commit1f097d168d9cad473dd44010a337c1413a9cd198 (patch)
tree66c6be8064c702d14d2038c7339f75105476eb72 /libavcodec
parente46ad30a808744ddf3855567e162292a4eaabac7 (diff)
downloadffmpeg-1f097d168d9cad473dd44010a337c1413a9cd198.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
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index fd9f7962d2..da2d4a55fa 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1764,7 +1764,6 @@ static int decode_update_thread_context(AVCodecContext *dst,
h->picture_structure = h1->picture_structure;
h->qscale = h1->qscale;
h->droppable = h1->droppable;
- h->data_partitioning = h1->data_partitioning;
h->low_delay = h1->low_delay;
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
@@ -4745,6 +4744,13 @@ again:
}
break;
case NAL_DPA:
+ if (h->avctx->flags & CODEC_FLAG2_CHUNKS) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "Decoding in chunks is not supported for "
+ "partitioned slices.\n");
+ return AVERROR(ENOSYS);
+ }
+
init_get_bits(&hx->gb, ptr, bit_length);
hx->intra_gb_ptr =
hx->inter_gb_ptr = NULL;
@@ -4894,6 +4900,9 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
int ret;
h->flags = avctx->flags;
+ /* reset data partitioning here, to ensure GetBitContexts from previous
+ * packets do not get used. */
+ h->data_partitioning = 0;
/* end of stream, output what is still in the buffers */
out: