test/evp_test.c:707: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 680, column 10 is not reachable after line 707, column 5.
Showing all 42 steps of the trace


test/evp_test.c:671:1: start of procedure digest_test_run()
669.   }
670.   
671. > static int digest_test_run(EVP_TEST *t)
672.   {
673.       DIGEST_DATA *mdata = t->data;

test/evp_test.c:673:5: 
671.   static int digest_test_run(EVP_TEST *t)
672.   {
673. >     DIGEST_DATA *mdata = t->data;
674.       size_t i;
675.       EVP_MD_CTX *mctx;

test/evp_test.c:679:5: 
677.       unsigned int md_len;
678.   
679. >     t->err = "TEST_FAILURE";
680.       if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
681.           goto err;

test/evp_test.c:680:10: 
678.   
679.       t->err = "TEST_FAILURE";
680. >     if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
681.           goto err;
682.   

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

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/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

test/testutil/tests.c:462:1: start of procedure test_ptr()
  460.   }
  461.   
  462. > int test_ptr(const char *file, int line, const char *s, const void *p)
  463.   {
  464.       if (p != NULL)

test/testutil/tests.c:464:9: Taking true branch
  462.   int test_ptr(const char *file, int line, const char *s, const void *p)
  463.   {
  464.       if (p != NULL)
                 ^
  465.           return 1;
  466.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:465:9: 
  463.   {
  464.       if (p != NULL)
  465. >         return 1;
  466.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  467.       return 0;

test/testutil/tests.c:468:1: return from a call to test_ptr
  466.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  467.       return 0;
  468. > }
  469.   
  470.   int test_true(const char *file, int line, const char *s, int b)

test/evp_test.c:680:10: Taking false branch
678.   
679.       t->err = "TEST_FAILURE";
680.       if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
                ^
681.           goto err;
682.   

test/evp_test.c:683:10: Taking true branch
681.           goto err;
682.   
683.       if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL)) {
                ^
684.           t->err = "DIGESTINIT_ERROR";
685.           goto err;

test/evp_test.c:684:9: 
682.   
683.       if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL)) {
684. >         t->err = "DIGESTINIT_ERROR";
685.           goto err;
686.       }

test/evp_test.c:706:2: 
704.       t->err = NULL;
705.   
706. >  err:
707.       EVP_MD_CTX_free(mctx);
708.       return 1;

test/evp_test.c:707:5: 
705.   
706.    err:
707. >     EVP_MD_CTX_free(mctx);
708.       return 1;
709.   }

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

static int digest_test_run(EVP_TEST *t)
{
    DIGEST_DATA *mdata = t->data;
    size_t i;
    EVP_MD_CTX *mctx;
    unsigned char md[EVP_MAX_MD_SIZE];
    unsigned int md_len;
    t->err = "TEST_FAILURE";
    if (!TEST_ptr(mctx = EVP_MD_CTX_new()))
        goto err;
    if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL)) {
        t->err = "DIGESTINIT_ERROR";
        goto err;
    }
    for (i = 0; i < mdata->nrpt; i++)
        if (!EVP_DigestUpdate(mctx, mdata->input, mdata->input_len)) {
            t->err = "DIGESTUPDATE_ERROR";
            goto err;
        }
    if (!EVP_DigestFinal(mctx, md, &md_len)) {
        t->err = "DIGESTFINAL_ERROR";
        goto err;
    }
    if (md_len != mdata->output_len) {
        t->err = "DIGEST_LENGTH_MISMATCH";
        goto err;
    }
    if (!compare_mem(mdata->output, mdata->output_len, md, md_len)) {
        t->err = "DIGEST_MISMATCH";
        goto err;
    }
    t->err = NULL;
 err:
    EVP_MD_CTX_free(mctx);
    return 1;
}
['static int digest_test_run(EVP_TEST *t)\n{\n    DIGEST_DATA *mdata = t->data;\n    size_t i;\n    EVP_MD_CTX *mctx;\n    unsigned char md[EVP_MAX_MD_SIZE];\n    unsigned int md_len;\n    t->err = "TEST_FAILURE";\n    if (!TEST_ptr(mctx = EVP_MD_CTX_new()))\n        goto err;\n    if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL)) {\n        t->err = "DIGESTINIT_ERROR";\n        goto err;\n    }\n    for (i = 0; i < mdata->nrpt; i++)\n        if (!EVP_DigestUpdate(mctx, mdata->input, mdata->input_len)) {\n            t->err = "DIGESTUPDATE_ERROR";\n            goto err;\n        }\n    if (!EVP_DigestFinal(mctx, md, &md_len)) {\n        t->err = "DIGESTFINAL_ERROR";\n        goto err;\n    }\n    if (md_len != mdata->output_len) {\n        t->err = "DIGEST_LENGTH_MISMATCH";\n        goto err;\n    }\n    if (!compare_mem(mdata->output, mdata->output_len, md, md_len)) {\n        t->err = "DIGEST_MISMATCH";\n        goto err;\n    }\n    t->err = NULL;\n err:\n    EVP_MD_CTX_free(mctx);\n    return 1;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_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}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']