mirror of
https://github.com/openssl/openssl.git
synced 2026-01-18 17:11:31 +01:00
ctx_simd and ctx_ref must be freed in error path
CID 1679597 CID 1679599 Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Norbert Pocs <norbertp@openssl.org> MergeDate: Thu Jan 8 10:10:49 2026 (Merged from https://github.com/openssl/openssl/pull/29543)
This commit is contained in:
committed by
Tomas Mraz
parent
b0041c909e
commit
818bbcf475
@@ -161,6 +161,8 @@ static int test_encode_line_lengths_reinforced(void)
|
||||
/* Generous output buffers (Update + Final + newlines), plus a guard byte */
|
||||
unsigned char out_simd[9000 * 2 + 1] = { 0 };
|
||||
unsigned char out_ref[9000 * 2 + 1] = { 0 };
|
||||
EVP_ENCODE_CTX *ctx_simd = NULL;
|
||||
EVP_ENCODE_CTX *ctx_ref = NULL;
|
||||
|
||||
for (int t = 0; t < trials; t++) {
|
||||
uint32_t r = next_u32(&seed);
|
||||
@@ -174,14 +176,12 @@ static int test_encode_line_lengths_reinforced(void)
|
||||
for (int partial_ctx_fill = 0; partial_ctx_fill <= 80;
|
||||
partial_ctx_fill += 1) {
|
||||
for (int ctx_len = 1; ctx_len <= 80; ctx_len += 1) {
|
||||
EVP_ENCODE_CTX *ctx_simd = EVP_ENCODE_CTX_new();
|
||||
EVP_ENCODE_CTX *ctx_ref = EVP_ENCODE_CTX_new();
|
||||
ctx_simd = EVP_ENCODE_CTX_new();
|
||||
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;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fuzz_fill_encode_ctx(ctx_simd, partial_ctx_fill);
|
||||
@@ -216,7 +216,7 @@ static int test_encode_line_lengths_reinforced(void)
|
||||
if (!TEST_int_eq(ret_simd, ret_ref)
|
||||
|| !TEST_mem_eq(out_ref, outlen_ref, out_simd, outlen_simd)
|
||||
|| !TEST_int_eq(outlen_simd, outlen_ref))
|
||||
return 0;
|
||||
goto fail;
|
||||
|
||||
EVP_EncodeFinal(ctx_simd, out_simd + outlen_simd,
|
||||
&finlen_simd);
|
||||
@@ -228,7 +228,7 @@ static int test_encode_line_lengths_reinforced(void)
|
||||
|
||||
if (!TEST_int_eq(finlen_simd, finlen_ref)
|
||||
|| !TEST_mem_eq(out_ref, total_ref, out_simd, total_simd))
|
||||
return 0;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
EVP_ENCODE_CTX_free(ctx_simd);
|
||||
@@ -238,6 +238,11 @@ static int test_encode_line_lengths_reinforced(void)
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
EVP_ENCODE_CTX_free(ctx_simd);
|
||||
EVP_ENCODE_CTX_free(ctx_ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setup_tests(void)
|
||||
|
||||
Reference in New Issue
Block a user