static int encode_test_run(EVP_TEST *t)
{
    ENCODE_DATA *edata = t->data;
    unsigned char *encode_out = NULL, *decode_out = NULL;
    int output_len, chunk_len;
    EVP_ENCODE_CTX *decode_ctx;
    if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
        t->err = "INTERNAL_ERROR";
        goto err;
    }
    if (edata->encoding == BASE64_CANONICAL_ENCODING) {
        EVP_ENCODE_CTX *encode_ctx;
        if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
                || !TEST_ptr(encode_out =
                        OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len))))
            goto err;
        EVP_EncodeInit(encode_ctx);
        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
                         edata->input, edata->input_len);
        output_len = chunk_len;
        EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);
        output_len += chunk_len;
        EVP_ENCODE_CTX_free(encode_ctx);
        if (!compare_mem(edata->output, edata->output_len,
                         encode_out, output_len)) {
            t->err = "BAD_ENCODING";
            goto err;
        }
    }
    if (!TEST_ptr(decode_out =
                OPENSSL_malloc(EVP_DECODE_LENGTH(edata->output_len))))
        goto err;
    EVP_DecodeInit(decode_ctx);
    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, edata->output,
                         edata->output_len) < 0) {
        t->err = "DECODE_ERROR";
        goto err;
    }
    output_len = chunk_len;
    if (EVP_DecodeFinal(decode_ctx, decode_out + chunk_len, &chunk_len) != 1) {
        t->err = "DECODE_ERROR";
        goto err;
    }
    output_len += chunk_len;
    if (edata->encoding != BASE64_INVALID_ENCODING
            && !compare_mem(edata->input, edata->input_len,
                            decode_out, output_len)) {
        t->err = "BAD_DECODING";
        goto err;
    }
    t->err = NULL;
 err:
    OPENSSL_free(encode_out);
    OPENSSL_free(decode_out);
    EVP_ENCODE_CTX_free(decode_ctx);
    return 1;
}
['static int encode_test_run(EVP_TEST *t)\n{\n    ENCODE_DATA *edata = t->data;\n    unsigned char *encode_out = NULL, *decode_out = NULL;\n    int output_len, chunk_len;\n    EVP_ENCODE_CTX *decode_ctx;\n    if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {\n        t->err = "INTERNAL_ERROR";\n        goto err;\n    }\n    if (edata->encoding == BASE64_CANONICAL_ENCODING) {\n        EVP_ENCODE_CTX *encode_ctx;\n        if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())\n                || !TEST_ptr(encode_out =\n                        OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len))))\n            goto err;\n        EVP_EncodeInit(encode_ctx);\n        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,\n                         edata->input, edata->input_len);\n        output_len = chunk_len;\n        EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);\n        output_len += chunk_len;\n        EVP_ENCODE_CTX_free(encode_ctx);\n        if (!compare_mem(edata->output, edata->output_len,\n                         encode_out, output_len)) {\n            t->err = "BAD_ENCODING";\n            goto err;\n        }\n    }\n    if (!TEST_ptr(decode_out =\n                OPENSSL_malloc(EVP_DECODE_LENGTH(edata->output_len))))\n        goto err;\n    EVP_DecodeInit(decode_ctx);\n    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, edata->output,\n                         edata->output_len) < 0) {\n        t->err = "DECODE_ERROR";\n        goto err;\n    }\n    output_len = chunk_len;\n    if (EVP_DecodeFinal(decode_ctx, decode_out + chunk_len, &chunk_len) != 1) {\n        t->err = "DECODE_ERROR";\n        goto err;\n    }\n    output_len += chunk_len;\n    if (edata->encoding != BASE64_INVALID_ENCODING\n            && !compare_mem(edata->input, edata->input_len,\n                            decode_out, output_len)) {\n        t->err = "BAD_DECODING";\n        goto err;\n    }\n    t->err = NULL;\n err:\n    OPENSSL_free(encode_out);\n    OPENSSL_free(decode_out);\n    EVP_ENCODE_CTX_free(decode_ctx);\n    return 1;\n}', 'EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'static void test_fail_message(const char *prefix, const char *file,\n                              int line, const char *type,\n                              const char *left, const char *right,\n                              const char *op, const char *fmt, ...)\n{\n    va_list ap;\n    va_start(ap, fmt);\n    test_fail_message_va(prefix, file, line, type, left, right, op, fmt, ap);\n    va_end(ap);\n}']