* [FFmpeg-devel] [PATCH] tests/checkasm/nlmeans: Add check for av_calloc
@ 2022-02-16 9:42 Jiasheng Jiang
0 siblings, 0 replies; only message in thread
From: Jiasheng Jiang @ 2022-02-16 9:42 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Jiasheng Jiang
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-16 9:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 9:42 [FFmpeg-devel] [PATCH] tests/checkasm/nlmeans: Add check for av_calloc Jiasheng Jiang
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