From: Neil Horman Date: Tue, 30 Dec 2025 17:19:05 +0000 (-0500) Subject: check for null returns in test_base64_simdutf.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e8a68008cc15e0c84cd2cf5e3c7ab998981df7e;p=thirdparty%2Fopenssl.git check for null returns in test_base64_simdutf.c We derferences two pointers in this code which we fail to check for null first. reported by: https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677832 Just move the null check a bit higher Reviewed-by: Saša Nedvědický Reviewed-by: Nikola Pajkovsky (Merged from https://github.com/openssl/openssl/pull/29525) --- diff --git a/test/test_base64_simdutf.c b/test/test_base64_simdutf.c index a39155dc44f..74cbab240a0 100644 --- a/test/test_base64_simdutf.c +++ b/test/test_base64_simdutf.c @@ -184,6 +184,13 @@ static int test_encode_line_lengths_reinforced(void) EVP_ENCODE_CTX *ctx_simd = EVP_ENCODE_CTX_new(); EVP_ENCODE_CTX *ctx_ref = EVP_ENCODE_CTX_new(); + if (!ctx_simd || !ctx_ref) { + EVP_ENCODE_CTX_free(ctx_simd); + EVP_ENCODE_CTX_free(ctx_ref); + TEST_error("Out of memory for contexts"); + return 0; + } + fuzz_fill_encode_ctx(ctx_simd, partial_ctx_fill); memset(out_simd, 0xCC, sizeof(out_simd)); /* poison to catch short writes */ @@ -192,13 +199,6 @@ static int test_encode_line_lengths_reinforced(void) int outlen_simd = 0, outlen_ref = 0; /* bytes produced by Update */ int finlen_simd = 0, finlen_ref = 0; /* bytes produced by Final */ - if (!ctx_simd || !ctx_ref) { - EVP_ENCODE_CTX_free(ctx_simd); - EVP_ENCODE_CTX_free(ctx_ref); - TEST_error("Out of memory for contexts"); - return 0; - } - EVP_EncodeInit(ctx_simd); EVP_EncodeInit(ctx_ref); ctx_simd->length = ctx_len;