From patchwork Thu Aug 29 19:04:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14798 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 ECD2C449EE7 for ; Thu, 29 Aug 2019 22:07:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7E74687F18; Thu, 29 Aug 2019 22:07:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 87DB468080C for ; Thu, 29 Aug 2019 22:07:07 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1i3PlD-0002p2-1q for ffmpeg-devel@ffmpeg.org; Thu, 29 Aug 2019 21:07:07 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 3PkEiGWTWwlys3PkFidOvC; Thu, 29 Aug 2019 21:06:07 +0200 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=E5OzWpVl c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=VNrV2ADypfvYtp587lwA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 29 Aug 2019 21:04:59 +0200 Message-Id: <20190829190459.5171-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829190459.5171-1-michael@niedermayer.cc> References: <20190829190459.5171-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfFv5Fv7y0ODsHz7WO/cctxNFI0+QCPu7dJ3xJbsdS4YuOBUEBlCzBUMXaEtcmABkLhVESc7oMEO5Y2pS/XymsX9eEijlzQW4BzXLU+98UmX5KmfqlRm7 RYIPGQb0TFbwhb03Wte+AMAwBFVJO1h5Nog8iy/WEje5f5jWBcGRKLzH Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/arbc: Use ff_reget_buffer() 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" Fixes: Timeout (20sec -> 0.5sec) Fixes: 16404/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5660216355454976 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/arbc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c index 06970f140b..f0de50e243 100644 --- a/libavcodec/arbc.c +++ b/libavcodec/arbc.c @@ -136,15 +136,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, if (7 * nb_segments > bytestream2_get_bytes_left(&s->gb)) return AVERROR_INVALIDDATA; - if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) + if ((ret = ff_reget_buffer(avctx, s->prev_frame)) < 0) return ret; - if (s->prev_frame->data[0]) { - ret = av_frame_copy(frame, s->prev_frame); - if (ret < 0) - return ret; - } - for (int i = 0; i < nb_segments; i++) { int resolution_flag; int fill; @@ -161,19 +155,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, resolution_flag = bytestream2_get_byte(&s->gb); if (resolution_flag & 0x10) - prev_pixels -= fill_tileX(avctx, 1024, 1024, fill, frame); + prev_pixels -= fill_tileX(avctx, 1024, 1024, fill, s->prev_frame); if (resolution_flag & 0x08) - prev_pixels -= fill_tileX(avctx, 256, 256, fill, frame); + prev_pixels -= fill_tileX(avctx, 256, 256, fill, s->prev_frame); if (resolution_flag & 0x04) - prev_pixels -= fill_tileX(avctx, 64, 64, fill, frame); + prev_pixels -= fill_tileX(avctx, 64, 64, fill, s->prev_frame); if (resolution_flag & 0x02) - prev_pixels -= fill_tileX(avctx, 16, 16, fill, frame); + prev_pixels -= fill_tileX(avctx, 16, 16, fill, s->prev_frame); if (resolution_flag & 0x01) - prev_pixels -= fill_tile4(avctx, fill, frame); + prev_pixels -= fill_tile4(avctx, fill, s->prev_frame); } - av_frame_unref(s->prev_frame); - if ((ret = av_frame_ref(s->prev_frame, frame)) < 0) + if ((ret = av_frame_ref(frame, s->prev_frame)) < 0) return ret; frame->pict_type = prev_pixels <= 0 ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;