From patchwork Mon May 31 07:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656438iof; Mon, 31 May 2021 00:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ60zQad6D7ojOMV2ob1S7R1EJKNLyPhdoJcyciRKOS1Roe6jUZYC8ZURWV728LHUl3P4o X-Received: by 2002:a17:906:131a:: with SMTP id w26mr21050974ejb.198.1622447795206; Mon, 31 May 2021 00:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447795; cv=none; d=google.com; s=arc-20160816; b=XqQiUugtlD51Wvc3jR2NjSdvZXdlF/UWgkIs7Rim3e+o2wKYwWKeLA+Bkaz5hISgcQ ag0uDBxyOvjkFDa35WgM6dfuHHAdJki980l+FkfoVYSkWxm6ihtw9RJ9XohTdA06G05W t0cGyUg42Ly0nFAigdzjtFZa8QRgZFNvV6Qujr7r5V00uS+tByI1v9DE0HsovDAnbpbD bSp/bjvEjbAUHE8Rgh9AP4EkdkCwhaYP0P2NUCScHsgBSxpM+RSz6L7t7SYS93l/iWda Q8bsugJCfFRMaowgz96sDWFQpw3go1zCcNO7EXCVLBg3csRYlNsY001hN/FpLSZOPQQM RUng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=qCVv06I1AzdGWpSvnruDsug4EwmY7hkT2zReOrkbpkE=; b=Avit06pFYiSv/1k5Lex8ipCwLXeRChBih30Ja+K+aj39JrT9Is6V19tjtZDdi2Kx6K JixF7QAG6W0rIbQi0fQC4llXWiicSZQKIS+pG6aCcYzxD42ELsxWsmBMkYBDh0iGOG+3 /8mzQpyaP4ejRkqI4Tif4s8zIwPn80dPuDa67mBRJi75RIeka5uk1AE4Dt60wBC/SZxe Z9eG2BGPsCdEzFFddupNDyZnCb7LFkm1KMHawDczoSYIRDIEBGIaif5vYbHoW90t1kds IViX5NxaO1AabqH9Dxzje0jZhI3DfLej5LpIQf5HNmrKJ6i/te5olpJ5wHIdGZtD+ZDn HuOA== 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 w9si12742250edx.381.2021.05.31.00.56.34; Mon, 31 May 2021 00:56:35 -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 EB3D4689247; Mon, 31 May 2021 10:55:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC20868804B for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4B349240694 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZsuJy9QnGD1o for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id F01CA24069A for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 016C83A1563; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:01 +0200 Message-Id: <20210531075515.19544-10-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/24] sws: group the parameters validity checks together X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 8wbOdvINrfOO Also, fail with an error code rather than 0. --- libswscale/swscale.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1cf89e4684..37c7cf60dd 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -890,6 +890,15 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } + if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { + av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); + return AVERROR(EINVAL); + } + if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { + av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); + return AVERROR(EINVAL); + } + if (c->gamma_flag && c->cascaded_context[0]) return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); @@ -905,15 +914,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (srcSliceH == 0) return 0; - if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { - av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); - return 0; - } - if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { - av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); - return 0; - } - if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0;