test/evp_test.c:1559: error: MEMORY_LEAK
  memory dynamically allocated to `encode_ctx` by call to `EVP_ENCODE_CTX_new()` at line 1558, column 14 is not reachable after line 1559, column 21.
Showing all 67 steps of the trace


test/evp_test.c:1543:1: start of procedure encode_test_run()
1541.   }
1542.   
1543. > static int encode_test_run(EVP_TEST *t)
1544.   {
1545.       ENCODE_DATA *expected = t->data;

test/evp_test.c:1545:5: 
1543.   static int encode_test_run(EVP_TEST *t)
1544.   {
1545. >     ENCODE_DATA *expected = t->data;
1546.       unsigned char *encode_out = NULL, *decode_out = NULL;
1547.       int output_len, chunk_len;

test/evp_test.c:1546:5: 
1544.   {
1545.       ENCODE_DATA *expected = t->data;
1546. >     unsigned char *encode_out = NULL, *decode_out = NULL;
1547.       int output_len, chunk_len;
1548.       EVP_ENCODE_CTX *decode_ctx;

test/evp_test.c:1550:10: 
1548.       EVP_ENCODE_CTX *decode_ctx;
1549.   
1550. >     if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
1551.           t->err = "INTERNAL_ERROR";
1552.           goto err;

crypto/evp/encode.c:96:1: start of procedure EVP_ENCODE_CTX_new()
  94.   #endif
  95.   
  96. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:98:5: 
  96.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98. >     return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99.   }
  100.   

crypto/mem.c:197:1: start of procedure CRYPTO_zalloc()
    195.   }
    196.   
    197. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:199:5: 
    197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199. >     void *ret = CRYPTO_malloc(num, file, line);
    200.   
    201.       FAILTEST();

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
      167.   #endif
      168.   
      169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      170.   {
      171.       void *ret = NULL;

crypto/mem.c:171:5: 
      169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      170.   {
      171. >     void *ret = NULL;
      172.   
      173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking false branch
      171.       void *ret = NULL;
      172.   
      173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      174.           return malloc_impl(num, file, line);
      175.   

crypto/mem.c:176:9: Taking false branch
      174.           return malloc_impl(num, file, line);
      175.   
      176.       if (num == 0)
                     ^
      177.           return NULL;
      178.   

crypto/mem.c:180:5: 
      178.   
      179.       FAILTEST();
      180. >     allow_customize = 0;
      181.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      182.       if (call_malloc_debug) {

crypto/mem.c:190:5: 
      188.       }
      189.   #else
      190. >     osslargused(file); osslargused(line);
      191.       ret = malloc(num);
      192.   #endif

crypto/mem.c:190:24: 
      188.       }
      189.   #else
      190. >     osslargused(file); osslargused(line);
      191.       ret = malloc(num);
      192.   #endif

crypto/mem.c:191:5: 
      189.   #else
      190.       osslargused(file); osslargused(line);
      191. >     ret = malloc(num);
      192.   #endif
      193.   

crypto/mem.c:194:5: 
      192.   #endif
      193.   
      194. >     return ret;
      195.   }
      196.   

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
      193.   
      194.       return ret;
      195. > }
      196.   
      197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:202:9: Taking true branch
    200.   
    201.       FAILTEST();
    202.       if (ret != NULL)
                   ^
    203.           memset(ret, 0, num);
    204.       return ret;

crypto/mem.c:203:9: 
    201.       FAILTEST();
    202.       if (ret != NULL)
    203. >         memset(ret, 0, num);
    204.       return ret;
    205.   }

crypto/mem.c:204:5: 
    202.       if (ret != NULL)
    203.           memset(ret, 0, num);
    204. >     return ret;
    205.   }
    206.   

crypto/mem.c:205:1: return from a call to CRYPTO_zalloc
    203.           memset(ret, 0, num);
    204.       return ret;
    205. > }
    206.   
    207.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/encode.c:99:1: return from a call to EVP_ENCODE_CTX_new
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99. > }
  100.   
  101.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1550:10: Taking false branch
1548.       EVP_ENCODE_CTX *decode_ctx;
1549.   
1550.       if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
                 ^
1551.           t->err = "INTERNAL_ERROR";
1552.           goto err;

test/evp_test.c:1555:9: Taking true branch
1553.       }
1554.   
1555.       if (expected->encoding == BASE64_CANONICAL_ENCODING) {
                ^
1556.           EVP_ENCODE_CTX *encode_ctx;
1557.   

test/evp_test.c:1558:14: 
1556.           EVP_ENCODE_CTX *encode_ctx;
1557.   
1558. >         if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1559.                   || !TEST_ptr(encode_out =
1560.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(expected->input_len))))

crypto/evp/encode.c:96:1: start of procedure EVP_ENCODE_CTX_new()
  94.   #endif
  95.   
  96. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:98:5: 
  96.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98. >     return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99.   }
  100.   

crypto/mem.c:197:1: start of procedure CRYPTO_zalloc()
    195.   }
    196.   
    197. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:199:5: 
    197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199. >     void *ret = CRYPTO_malloc(num, file, line);
    200.   
    201.       FAILTEST();

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
      167.   #endif
      168.   
      169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      170.   {
      171.       void *ret = NULL;

crypto/mem.c:171:5: 
      169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      170.   {
      171. >     void *ret = NULL;
      172.   
      173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking false branch
      171.       void *ret = NULL;
      172.   
      173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      174.           return malloc_impl(num, file, line);
      175.   

crypto/mem.c:176:9: Taking false branch
      174.           return malloc_impl(num, file, line);
      175.   
      176.       if (num == 0)
                     ^
      177.           return NULL;
      178.   

crypto/mem.c:180:5: 
      178.   
      179.       FAILTEST();
      180. >     allow_customize = 0;
      181.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      182.       if (call_malloc_debug) {

crypto/mem.c:190:5: 
      188.       }
      189.   #else
      190. >     osslargused(file); osslargused(line);
      191.       ret = malloc(num);
      192.   #endif

crypto/mem.c:190:24: 
      188.       }
      189.   #else
      190. >     osslargused(file); osslargused(line);
      191.       ret = malloc(num);
      192.   #endif

crypto/mem.c:191:5: 
      189.   #else
      190.       osslargused(file); osslargused(line);
      191. >     ret = malloc(num);
      192.   #endif
      193.   

crypto/mem.c:194:5: 
      192.   #endif
      193.   
      194. >     return ret;
      195.   }
      196.   

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
      193.   
      194.       return ret;
      195. > }
      196.   
      197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:202:9: Taking true branch
    200.   
    201.       FAILTEST();
    202.       if (ret != NULL)
                   ^
    203.           memset(ret, 0, num);
    204.       return ret;

crypto/mem.c:203:9: 
    201.       FAILTEST();
    202.       if (ret != NULL)
    203. >         memset(ret, 0, num);
    204.       return ret;
    205.   }

crypto/mem.c:204:5: 
    202.       if (ret != NULL)
    203.           memset(ret, 0, num);
    204. >     return ret;
    205.   }
    206.   

crypto/mem.c:205:1: return from a call to CRYPTO_zalloc
    203.           memset(ret, 0, num);
    204.       return ret;
    205. > }
    206.   
    207.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/encode.c:99:1: return from a call to EVP_ENCODE_CTX_new
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99. > }
  100.   
  101.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1558:14: Taking false branch
1556.           EVP_ENCODE_CTX *encode_ctx;
1557.   
1558.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
                     ^
1559.                   || !TEST_ptr(encode_out =
1560.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(expected->input_len))))

test/evp_test.c:1559:21: 
1557.   
1558.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1559. >                 || !TEST_ptr(encode_out =
1560.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(expected->input_len))))
1561.               goto err;

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
  167.   #endif
  168.   
  169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171.       void *ret = NULL;

crypto/mem.c:171:5: 
  169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171. >     void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking true branch
  171.       void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  174.           return malloc_impl(num, file, line);
  175.   

crypto/mem.c:173:32: Taking true branch
  171.       void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  174.           return malloc_impl(num, file, line);
  175.   

crypto/mem.c:174:9: Skipping __function_pointer__(): unresolved function pointer
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  174.           return malloc_impl(num, file, line);
                 ^
  175.   
  176.       if (num == 0)

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
  193.   
  194.       return ret;
  195. > }
  196.   
  197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking false branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:5: Skipping test_fail_message(): empty list of specs
  229.       if (p != NULL)
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
             ^
  232.       return 0;
  233.   }

test/testutil/tests.c:232:5: 
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232. >     return 0;
  233.   }
  234.   

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1559:21: Taking true branch
1557.   
1558.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1559.                   || !TEST_ptr(encode_out =
                            ^
1560.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(expected->input_len))))
1561.               goto err;

static int encode_test_run(EVP_TEST *t)
{
    ENCODE_DATA *expected = 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 (expected->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(expected->input_len))))
            goto err;
        EVP_EncodeInit(encode_ctx);
        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
                         expected->input, expected->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 (!TEST_mem_eq(expected->output, expected->output_len,
                         encode_out, output_len)) {
            t->err = "BAD_ENCODING";
            goto err;
        }
    }
    if (!TEST_ptr(decode_out =
                OPENSSL_malloc(EVP_DECODE_LENGTH(expected->output_len))))
        goto err;
    EVP_DecodeInit(decode_ctx);
    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, expected->output,
                         expected->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 (expected->encoding != BASE64_INVALID_ENCODING
            && !TEST_mem_eq(expected->input, expected->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 *expected = 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 (expected->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(expected->input_len))))\n            goto err;\n        EVP_EncodeInit(encode_ctx);\n        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,\n                         expected->input, expected->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 (!TEST_mem_eq(expected->output, expected->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(expected->output_len))))\n        goto err;\n    EVP_DecodeInit(decode_ctx);\n    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, expected->output,\n                         expected->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 (expected->encoding != BASE64_INVALID_ENCODING\n            && !TEST_mem_eq(expected->input, expected->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}']