From patchwork Wed Feb 16 09:42:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 34336 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:90eb:0:0:0:0 with SMTP id a11csp1065598nkf; Wed, 16 Feb 2022 01:42:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVJl4NOCDK0BrD4f40bw/SM7SNYyQU2n1Fk29BzD7+UFI4J4m1YjlcCht59PpP8wxAE/Vp X-Received: by 2002:aa7:d6c3:0:b0:40f:405a:fbf8 with SMTP id x3-20020aa7d6c3000000b0040f405afbf8mr1918072edr.447.1645004540264; Wed, 16 Feb 2022 01:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645004540; cv=none; d=google.com; s=arc-20160816; b=qdXP7zcanwVW+2ppVpWGGLsy3wOGRxE+nIx4sl0EnX3uQNcVBykgjFGudveKMI6uZS zVLNUdCm5ZnC2bow4+JmMtSsktOct2W9GzsACaBwYNqHbJthZ37G6O9eGwOfv2BVcyeE AQFpbbs+16vaikY/8DdnxoEkBRx/3YNaP11N3+udVfi6Z6o+ESb7ImKUZvbDtFn1R2ID BkqVkvvNnbzX48MCfVvtqHl/41aTKMG4sisuG3BYayvLfVTwLAOxPJ+VpcLhVhBqPn0c Ir9qB8LuovHsS24BZ46pVUNCScdvenrJfYDBisFLXSOge/lXWPMGFYjXBdo9jucjxPCL C70w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=KP9OsZNIEfxFwYZYYMBVXu4Rvc5GgXq8zLVHvJDy1Ws=; b=OwVZsypNZQ9NCmQl+hi0YLIKHGhRGw9DUmpYcCRTHP/wwaCrCAU4JxJuvzOoYQ0cks q9xavz51LdKw68hxvNDhnJxtq2QkeUMF5gdGDGD6S+srZ9RtOulMe1Velat1ky+seWf3 4Nd0RUKBzSTYHAinwa0HnIy/7DSwaiVwQ2+UylkWpoUsb7LL7D3tS+kFTugsHQOjmUUc R9iQ4yBUYARltzRAgdaU2lyMfuulA1xVZPVAYSQdGdFC/SOw92Ap7zTjo4KLgTYSg/Da kou04JtK0tBij7JEWQCKSxRm+6sETecSe73m2lDujfYwI/bvDGBqxAxcCzJK6LQ3wjws +MOA== 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 w25si1511932edt.600.2022.02.16.01.42.19; Wed, 16 Feb 2022 01:42:20 -0800 (PST) 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 BCA9C68B23B; Wed, 16 Feb 2022 11:42:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F8FC68B10F for ; Wed, 16 Feb 2022 11:42:09 +0200 (EET) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowAA3GfLsxgxiMbTZAA--.59458S2; Wed, 16 Feb 2022 17:42:05 +0800 (CST) From: Jiasheng Jiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Feb 2022 17:42:03 +0800 Message-Id: <20220216094203.2288551-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowAA3GfLsxgxiMbTZAA--.59458S2 X-Coremail-Antispam: 1UD129KBjvJXoW7WFy7WF17CF13Aw48GFy7GFg_yoW8XrW3p3 Z7KryvvrZ5GF12gr4Dtw1rXFyrKan5JF1jkr92v3WDAr4rJrWv9rWSkw48uF1F9rW7XFyf AFn5J3WS9F1rCaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkm14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GFWl 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU0VyxDUUUU X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Subject: [FFmpeg-devel] [PATCH] tests/checkasm/nlmeans: Add check for av_calloc 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 Cc: Jiasheng Jiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: caTiZ6/d3flp As the potential failure of the av_calloc(), it should be better to check it and fail() if fails in order to avoid the dereference of the NULL pointer. Fixes: f679711c1b ("checkasm: add vf_nlmeans test for ssd_integral_image") Signed-off-by: Jiasheng Jiang --- tests/checkasm/vf_nlmeans.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/checkasm/vf_nlmeans.c b/tests/checkasm/vf_nlmeans.c index 87474d6803..82370bbeec 100644 --- a/tests/checkasm/vf_nlmeans.c +++ b/tests/checkasm/vf_nlmeans.c @@ -47,9 +47,9 @@ void checkasm_check_nlmeans(void) const int ii_h = h + e*2; const int ii_lz_32 = FFALIGN(ii_w + 1, 4); uint32_t *ii_orig_ref = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_ref)); - uint32_t *ii_ref = ii_orig_ref + ii_lz_32 + 1; + uint32_t *ii_ref; uint32_t *ii_orig_new = av_calloc(ii_h + 1, ii_lz_32 * sizeof(*ii_orig_new)); - uint32_t *ii_new = ii_orig_new + ii_lz_32 + 1; + uint32_t *ii_new; const int src_lz = FFALIGN(w, 16); uint8_t *src = av_calloc(h, src_lz); @@ -58,6 +58,16 @@ void checkasm_check_nlmeans(void) const uint8_t *s2, ptrdiff_t linesize2, int w, int h); + if (!ii_orig_ref || !ii_orig_new || !src) { + av_free(ii_orig_ref); + av_free(ii_orig_new); + av_free(src); + fail(); + } + + ii_ref = ii_orig_ref + ii_lz_32 + 1; + ii_new = ii_orig_new + ii_lz_32 + 1; + randomize_buffer(src, h * src_lz); for (offy = -r; offy <= r; offy++) {