From 507b01f89969601f15555f7416804fb691632cbb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 31 Oct 2015 21:36:00 +0100 Subject: [PATCH] avcodec/h264_slice: Disable slice threads if there are multiple access units in a packet Fixes null pointer dereference Fixes Ticket4977 Signed-off-by: Michael Niedermayer --- libavcodec/h264_slice.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 3f41e9bbdd..eceda8a9bc 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1177,6 +1177,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n"); return AVERROR_INVALIDDATA; } + if (h->max_contexts > 1) { + if (!h->single_decode_warning) { + av_log(h->avctx, AV_LOG_WARNING, "Cannot decode multiple access units as slice threads\n"); + h->single_decode_warning = 1; + } + h->max_contexts = 1; + return SLICE_SINGLETHREAD; + } + if (h->cur_pic_ptr && FIELD_PICTURE(h) && h->first_field) { ret = ff_h264_field_end(h, h->slice_ctx, 1); h->current_slice = 0;