From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 20004412B9 for ; Wed, 16 Feb 2022 09:42:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B9D168B23A; Wed, 16 Feb 2022 11:42:17 +0200 (EET) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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++) { -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".