From patchwork Wed May 10 00:37:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 3636 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp1601101vsd; Tue, 9 May 2017 17:37:48 -0700 (PDT) X-Received: by 10.223.136.235 with SMTP id g40mr1860204wrg.107.1494376667967; Tue, 09 May 2017 17:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494376667; cv=none; d=google.com; s=arc-20160816; b=vgoGLOGe6Pz3LfAHAUJ3ZvO2MWawfG4eyk4BFiCtcYowNQRqHZOM7GWZLl7spTL2SJ KrCOafwZY0aeHXQqbgqs/bKHKAS9iNCmvedddMYj+EXd3cAnoL/CJf7spBl7xarBujyO vOQf/xDiuMqAqMaUCf33/+yXaDfZbJd0sv4Vc6R0IYhxb/uS7smvO1LzuBJkM97GQGnV 7QxuPBSX9uzbzjNvFh5QlDVVGCLS4+Ae3uFifFbhaaCu4Zd2939IUFgj+3E2tacvhxGl mX5fqqqgI3uDrRi0QR2mdD3uPGJzwV0bccCkFlLWGUdsjgH3lk5AsRWJuhr6JvSyVSR4 keRg== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Iz3BNFphagu+wduKHNCfDHPqULS8XCAdt2W3IuPiOGA=; b=jdynb1019w0pNWXIFqycZgr5rUXy1SnWgLubA1sEEWmqhBqUN3S9EBhuosMrki5HPp X6mt9S2tMsXm3dkLUGCV4PUuRhUclU+1whRw0CVKy/IVzH6B0oJ2B/xuPw2JLDzg6i7h Ocy/fT8mVfn4TWh27JkxUUVXj/LW+yM2W5qIcvD91bP2o+3/wFTAk0wx0NoCVGgj9RHL HjMvAux1R4NNzF9VohDO5oXOGgJE0bsrgjxcWxLKts42amZtHxjhCOVwXU+c2uj6IxgT AxbWw0rUejakkbTQm0FaRlAOwFmpauSMsv/07jX0FxDC58nikCE64S7YUnUjbzt78JAT vONQ== 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 l66si1427383wrc.285.2017.05.09.17.37.47; Tue, 09 May 2017 17:37:47 -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 42CB06809F5; Wed, 10 May 2017 03:37:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (vie01a-qmta-pe02-3.mx.upcmail.net [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1986368046E for ; Wed, 10 May 2017 03:37:31 +0300 (EEST) Received: from [172.31.218.46] (helo=vie01a-dmta-pe05-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1d8FdJ-0004Ye-7F for ffmpeg-devel@ffmpeg.org; Wed, 10 May 2017 02:37:37 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1d8FdD-0000cp-8I for ffmpeg-devel@ffmpeg.org; Wed, 10 May 2017 02:37:31 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id JQdN1v01Q0S5wYM01QdP5s; Wed, 10 May 2017 02:37:24 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 10 May 2017 02:37:22 +0200 Message-Id: <20170510003722.30567-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] avcodec/webp: Reinitilaize VP8 decoder on pixel format mismatch 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: out of array access Fixes: 1434/clusterfuzz-testcase-minimized-6314998085189632 Fixes: 1435/clusterfuzz-testcase-minimized-6483783723253760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/webp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 16c3ae2662..23ed4bc26f 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1330,12 +1330,17 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, WebPContext *s = avctx->priv_data; AVPacket pkt; int ret; + enum AVPixelFormat wanted_pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; + + if (s->initialized && wanted_pix_fmt != avctx->pix_fmt) { + ff_vp8_decode_free(avctx); + s->initialized = 0; + } if (!s->initialized) { ff_vp8_decode_init(avctx); s->initialized = 1; - if (s->has_alpha) - avctx->pix_fmt = AV_PIX_FMT_YUVA420P; + avctx->pix_fmt = wanted_pix_fmt; } s->lossless = 0;