From patchwork Sat Sep 9 23:32:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5069 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp1582216jaa; Sat, 9 Sep 2017 16:33:22 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6MKTuCB9nW0AbyhRiP27vCIUklHueB86X+3Jh/NkFiXW0j0cfLky5HVsarKa+KebSzaArA X-Received: by 10.223.169.83 with SMTP id u77mr4757312wrc.268.1505000002632; Sat, 09 Sep 2017 16:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505000002; cv=none; d=google.com; s=arc-20160816; b=EARLXVsVE/H2SE/mjvWqkzycdTTnSsVn7VfRXmXqS2kQiZx7TrrtIZXl3/C4yK58Dm TDnNS3YgvzwBLuo/szGHKhD3V9vb6r9IGnseWiyQ/4IxkogPtGC7aSSCg5er2Iy6un/r SnCg8bviLhFWc66fiReGWEwslsizh03X7/CtTXX8JCXTZky+p8cmUdlKShaIYQkNp6KR VpTH8LGuWxhLtzBPM9U2X7hzsjUXAdyojXuFFXhYmi11P+IJNuyDen+uLRPLmT4mQfd4 BB9AQvZ/ObbIj9kd1UT7d/fLXM1aSY6Z5CKsB6CNQ5GA0Que061If/2LNxIW+uIFbImP ulQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=wtOLc60LdeA3C2NOpTwhciyuTCqqq4gx1QgjJjWurbA=; b=tGGN4AlTkSndOUJKiEhfEd2YVZ8puV1uxNYFO1PW6F+uWe59P7mXzq4AR9a6Ed27H5 QFuddndnZWI3ItmK5gEvKAhImh/fsQh5wkD/fX3Gyo6YbV6OU/urez0DKhxYq2aCrnHY dxo37OdfOl6ftaf3+IZ9hk1yh/8kH1VHlygq6StBGzcxFNuSKVeojp1yM58dMtMF428Y nAsWudhhkvHMbPtn3GkhOMnQzWfgMC4Ehj4aZgXsmD3XtXL0dmbB2ksP0M0A1cJ0Y6FT Ta1+MjphF+mTLZ9bBq9CP1IvMORxmEmh9yv95n/042rYzEmjkpeYNZPU0MAAuTtIDFVx 8cGQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l192si3955357wmg.242.2017.09.09.16.33.21; Sat, 09 Sep 2017 16:33:22 -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 B02A56808BE; Sun, 10 Sep 2017 02:33:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (vie01a-dmta-pe04-3.mx.upcmail.net [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2627F689A73 for ; Sun, 10 Sep 2017 02:33:09 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dqpFR-0003ib-0M for ffmpeg-devel@ffmpeg.org; Sun, 10 Sep 2017 01:33:13 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 7bYv1w01G0S5wYM01bYwEN; Sun, 10 Sep 2017 01:32:56 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 10 Sep 2017 01:32:52 +0200 Message-Id: <20170909233252.23566-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170909233252.23566-1-michael@niedermayer.cc> References: <20170909233252.23566-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/clearvideo: Only output a frame if one is coded in the packet 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" Fixes: Timeout (183 ms instead of about 20 sec) Fixes: 3147/clusterfuzz-testcase-4870592182353920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/clearvideo.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index a9fa0228bd..067942a131 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -290,11 +290,6 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data, } frame_type = bytestream2_get_byte(&gb); - if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) - return ret; - - c->pic->key_frame = frame_type & 0x20 ? 1 : 0; - c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (frame_type & 0x2) { if (buf_size < c->mb_width * c->mb_height) { @@ -302,6 +297,12 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } + if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) + return ret; + + c->pic->key_frame = frame_type & 0x20 ? 1 : 0; + c->pic->pict_type = frame_type & 0x20 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + bytestream2_get_be32(&gb); // frame size; c->ac_quant = bytestream2_get_byte(&gb); c->luma_dc_quant = 32; @@ -323,13 +324,13 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data, mb_ret = ret; } } - } else { - } - if ((ret = av_frame_ref(data, c->pic)) < 0) - return ret; + if ((ret = av_frame_ref(data, c->pic)) < 0) + return ret; - *got_frame = 1; + *got_frame = 1; + } else { + } return mb_ret < 0 ? mb_ret : buf_size; }