From patchwork Fri Mar 15 00:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 12315 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 910E44495D5 for ; Fri, 15 Mar 2019 02:33:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73954689DC4; Fri, 15 Mar 2019 02:33:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-2.mx.upcmail.net (vie01a-dmta-pe07-2.mx.upcmail.net [84.116.36.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFC786802C4 for ; Fri, 15 Mar 2019 02:33:09 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1h4amb-0005AM-0b for ffmpeg-devel@ffmpeg.org; Fri, 15 Mar 2019 01:33:09 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 4akehirJmxLwq4akehKOgd; Fri, 15 Mar 2019 01:31:08 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=WaxylHpX c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=52_UW5XD6gOOeI1fAuoA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 15 Mar 2019 01:30:12 +0100 Message-Id: <20190315003013.4182-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfEu3nn4XlnBLu2BIFIhzbWhlrGVN6UjemYYiT8XAdpDzTa60Ut7RQIR6CENeqkPotmS91tTYZtSN2Umn9LE1DQX+SqsK9eoPyJOzfW3ai2HsZze5kw/r +DtnYJmTBfVUlZk+DPCXE9rZ+s/C2o/75vXECSrGBhItczv7bhPzKzyg Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/scpr: Perform frame copy later 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Optimization found while looking at 13442/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5758293933293568 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/scpr.c | 8 ++++---- libavcodec/scpr3.c | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index 750cf59fe4..e5d7d13cf0 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -409,6 +409,10 @@ static int decompress_p(AVCodecContext *avctx, } } + ret = av_frame_copy(s->current_frame, s->last_frame); + if (ret < 0) + return ret; + for (y = 0; y < s->nby; y++) { for (x = 0; x < s->nbx; x++) { int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16; @@ -549,10 +553,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } else if (type == 0 || type == 1) { frame->key_frame = 0; - ret = av_frame_copy(s->current_frame, s->last_frame); - if (ret < 0) - return ret; - if (s->version == 1 || s->version == 2) ret = decompress_p(avctx, (uint32_t *)s->current_frame->data[0], s->current_frame->linesize[0] / 4, diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index b59a8cc28f..f92ccfa902 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -1081,6 +1081,10 @@ static int decompress_p3(AVCodecContext *avctx, } } + ret = av_frame_copy(s->current_frame, s->last_frame); + if (ret < 0) + return ret; + for (y = 0; y < s->nby; y++) { for (x = 0; x < s->nbx; x++) { int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;