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


test/evp_test.c:1934:1: start of procedure encode_test_run()
1932.   }
1933.   
1934. > static int encode_test_run(EVP_TEST *t)
1935.   {
1936.       ENCODE_DATA *edata = t->data;

test/evp_test.c:1936:5: 
1934.   static int encode_test_run(EVP_TEST *t)
1935.   {
1936. >     ENCODE_DATA *edata = t->data;
1937.       unsigned char *encode_out = NULL, *decode_out = NULL;
1938.       int output_len, chunk_len;

test/evp_test.c:1937:5: 
1935.   {
1936.       ENCODE_DATA *edata = t->data;
1937. >     unsigned char *encode_out = NULL, *decode_out = NULL;
1938.       int output_len, chunk_len;
1939.       EVP_ENCODE_CTX *decode_ctx;

test/evp_test.c:1941:10: 
1939.       EVP_ENCODE_CTX *decode_ctx;
1940.   
1941. >     if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
1942.           t->err = "INTERNAL_ERROR";
1943.           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:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
      156.   #endif
      157.   
      158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160.       void *ret = NULL;

crypto/mem.c:160:5: 
      158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160. >     void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
      160.       void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      163.           return malloc_impl(num, file, line);
      164.   

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   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:615:1: start of procedure test_ptr()
  613.   }
  614.   
  615. > int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)

test/testutil/tests.c:617:9: Taking true branch
  615.   int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)
                 ^
  618.           return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:618:9: 
  616.   {
  617.       if (p != NULL)
  618. >         return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;

test/testutil/tests.c:621:1: return from a call to test_ptr
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;
  621. > }
  622.   
  623.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1941:10: Taking false branch
1939.       EVP_ENCODE_CTX *decode_ctx;
1940.   
1941.       if (!TEST_ptr(decode_ctx = EVP_ENCODE_CTX_new())) {
                 ^
1942.           t->err = "INTERNAL_ERROR";
1943.           goto err;

test/evp_test.c:1946:9: Taking true branch
1944.       }
1945.   
1946.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
                ^
1947.           EVP_ENCODE_CTX *encode_ctx;
1948.   

test/evp_test.c:1949:14: 
1947.           EVP_ENCODE_CTX *encode_ctx;
1948.   
1949. >         if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1950.                   || !TEST_ptr(encode_out =
1951.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->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:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
      156.   #endif
      157.   
      158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160.       void *ret = NULL;

crypto/mem.c:160:5: 
      158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160. >     void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
      160.       void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      163.           return malloc_impl(num, file, line);
      164.   

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   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:615:1: start of procedure test_ptr()
  613.   }
  614.   
  615. > int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)

test/testutil/tests.c:617:9: Taking true branch
  615.   int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)
                 ^
  618.           return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:618:9: 
  616.   {
  617.       if (p != NULL)
  618. >         return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;

test/testutil/tests.c:621:1: return from a call to test_ptr
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;
  621. > }
  622.   
  623.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1949:14: Taking false branch
1947.           EVP_ENCODE_CTX *encode_ctx;
1948.   
1949.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
                     ^
1950.                   || !TEST_ptr(encode_out =
1951.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len))))

test/evp_test.c:1950:21: 
1948.   
1949.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1950. >                 || !TEST_ptr(encode_out =
1951.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len))))
1952.               goto err;

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
  156.   #endif
  157.   
  158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160.       void *ret = NULL;

crypto/mem.c:160:5: 
  158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160. >     void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking true branch
  160.       void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  163.           return malloc_impl(num, file, line);
  164.   

crypto/mem.c:162:32: Taking true branch
  160.       void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  163.           return malloc_impl(num, file, line);
  164.   

crypto/mem.c:163:9: Skipping __function_pointer__(): unresolved function pointer
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  163.           return malloc_impl(num, file, line);
                 ^
  164.   
  165.       if (num == 0)

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
  182.   
  183.       return ret;
  184. > }
  185.   
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/testutil/tests.c:615:1: start of procedure test_ptr()
  613.   }
  614.   
  615. > int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)

test/testutil/tests.c:617:9: Taking false branch
  615.   int test_ptr(const char *file, int line, const char *s, const void *p)
  616.   {
  617.       if (p != NULL)
                 ^
  618.           return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:619:5: 
  617.       if (p != NULL)
  618.           return 1;
  619. >     test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;
  621.   }

test/testutil/tests.c:500:1: start of procedure test_fail_message()
    498.   }
    499.   
    500. > static void test_fail_message(const char *prefix, const char *file,
    501.                                 int line, const char *type,
    502.                                 const char *left, const char *right,

test/testutil/tests.c:507:5: 
    505.       va_list ap;
    506.   
    507. >     va_start(ap, fmt);
    508.       test_fail_message_va(prefix, file, line, type, left, right, op, fmt, ap);
    509.       va_end(ap);

test/testutil/tests.c:508:5: Skipping test_fail_message_va(): empty list of specs
    506.   
    507.       va_start(ap, fmt);
    508.       test_fail_message_va(prefix, file, line, type, left, right, op, fmt, ap);
               ^
    509.       va_end(ap);
    510.   }

test/testutil/tests.c:509:5: 
    507.       va_start(ap, fmt);
    508.       test_fail_message_va(prefix, file, line, type, left, right, op, fmt, ap);
    509. >     va_end(ap);
    510.   }
    511.   

test/testutil/tests.c:510:1: return from a call to test_fail_message
    508.       test_fail_message_va(prefix, file, line, type, left, right, op, fmt, ap);
    509.       va_end(ap);
    510. > }
    511.   
    512.   void test_info_c90(const char *desc, ...)

test/testutil/tests.c:620:5: 
  618.           return 1;
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620. >     return 0;
  621.   }
  622.   

test/testutil/tests.c:621:1: return from a call to test_ptr
  619.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  620.       return 0;
  621. > }
  622.   
  623.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:1950:21: Taking true branch
1948.   
1949.           if (!TEST_ptr(encode_ctx = EVP_ENCODE_CTX_new())
1950.                   || !TEST_ptr(encode_out =
                            ^
1951.                           OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len))))
1952.               goto err;

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}']