From patchwork Wed Jul 27 16:37:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp341617vsd; Wed, 27 Jul 2016 09:40:32 -0700 (PDT) X-Received: by 10.194.85.18 with SMTP id d18mr28527270wjz.43.1469637632406; Wed, 27 Jul 2016 09:40:32 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y204si8521755wme.44.2016.07.27.09.40.30; Wed, 27 Jul 2016 09:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9589768A5D7; Wed, 27 Jul 2016 19:40:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-1.mx.upcmail.net (vie01a-dmta-pe02-1.mx.upcmail.net [62.179.121.157]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ADADE68A5D1 for ; Wed, 27 Jul 2016 19:40:01 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bSRsL-0004us-0a for ffmpeg-devel@ffmpeg.org; Wed, 27 Jul 2016 18:40:05 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id Psg31t00h0S5wYM01sg4Jx; Wed, 27 Jul 2016 18:40:05 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 27 Jul 2016 18:37:17 +0200 Message-Id: <1469637437-9608-1-git-send-email-michael@niedermayer.cc> X-Mailer: git-send-email 1.7.9.5 Subject: [FFmpeg-devel] [PATCH] avcodec/h264_slice: Make setup_finished check cover more cases X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/h264_slice.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 74e8118..8d20028 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1563,12 +1563,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, if (ret < 0) return ret; + if (sl->first_mb_addr == 0 || !h->current_slice) { + if (h->setup_finished) { + av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n"); + return AVERROR_INVALIDDATA; + } + } + if (sl->first_mb_addr == 0) { // FIXME better field boundary detection if (h->current_slice) { - if (h->setup_finished) { - 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");