/* 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);
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);
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);
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);
}
return 1;
+
+fail:
+ EVP_ENCODE_CTX_free(ctx_simd);
+ EVP_ENCODE_CTX_free(ctx_ref);
+ return 0;
}
int setup_tests(void)