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 <jiash...@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-requ...@ffmpeg.org with subject "unsubscribe".