From: Jiasheng Jiang <jiasheng@iscas.ac.cn> To: ffmpeg-devel@ffmpeg.org Cc: Jiasheng Jiang <jiasheng@iscas.ac.cn> Subject: [FFmpeg-devel] [PATCH] tests/checkasm/nlmeans: Add check for av_calloc Date: Wed, 16 Feb 2022 17:42:03 +0800 Message-ID: <20220216094203.2288551-1-jiasheng@iscas.ac.cn> (raw) 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 <jiasheng@iscas.ac.cn> --- 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".
reply other threads:[~2022-02-16 9:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220216094203.2288551-1-jiasheng@iscas.ac.cn \ --to=jiasheng@iscas.ac.cn \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git