test/evp_extra_test.c:263: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 223, column 14 is not reachable after line 263, column 5.
Showing all 69 steps of the trace


test/evp_extra_test.c:215:1: start of procedure test_EVP_DigestSignInit()
213.   }
214.   
215. > static int test_EVP_DigestSignInit(void)
216.   {
217.       int ret = 0;

test/evp_extra_test.c:217:5: 
215.   static int test_EVP_DigestSignInit(void)
216.   {
217. >     int ret = 0;
218.       EVP_PKEY *pkey = NULL;
219.       unsigned char *sig = NULL;

test/evp_extra_test.c:218:5: 
216.   {
217.       int ret = 0;
218. >     EVP_PKEY *pkey = NULL;
219.       unsigned char *sig = NULL;
220.       size_t sig_len = 0;

test/evp_extra_test.c:219:5: 
217.       int ret = 0;
218.       EVP_PKEY *pkey = NULL;
219. >     unsigned char *sig = NULL;
220.       size_t sig_len = 0;
221.       EVP_MD_CTX *md_ctx, *md_ctx_verify;

test/evp_extra_test.c:220:5: 
218.       EVP_PKEY *pkey = NULL;
219.       unsigned char *sig = NULL;
220. >     size_t sig_len = 0;
221.       EVP_MD_CTX *md_ctx, *md_ctx_verify;
222.   

test/evp_extra_test.c:223:5: 
221.       EVP_MD_CTX *md_ctx, *md_ctx_verify;
222.   
223. >     md_ctx = EVP_MD_CTX_new();
224.       md_ctx_verify = EVP_MD_CTX_new();
225.       if (md_ctx == NULL || md_ctx_verify == NULL)

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/evp_extra_test.c:224:5: 
222.   
223.       md_ctx = EVP_MD_CTX_new();
224. >     md_ctx_verify = EVP_MD_CTX_new();
225.       if (md_ctx == NULL || md_ctx_verify == NULL)
226.           goto out;

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 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)

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

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/evp_extra_test.c:225:9: Taking false branch
223.       md_ctx = EVP_MD_CTX_new();
224.       md_ctx_verify = EVP_MD_CTX_new();
225.       if (md_ctx == NULL || md_ctx_verify == NULL)
               ^
226.           goto out;
227.   

test/evp_extra_test.c:225:27: Taking true branch
223.       md_ctx = EVP_MD_CTX_new();
224.       md_ctx_verify = EVP_MD_CTX_new();
225.       if (md_ctx == NULL || md_ctx_verify == NULL)
                                 ^
226.           goto out;
227.   

test/evp_extra_test.c:258:2: 
256.       ret = 1;
257.   
258. >  out:
259.       if (!ret) {
260.           ERR_print_errors_fp(stderr);

test/evp_extra_test.c:259:10: Taking true branch
257.   
258.    out:
259.       if (!ret) {
                ^
260.           ERR_print_errors_fp(stderr);
261.       }

test/evp_extra_test.c:260:9: 
258.    out:
259.       if (!ret) {
260. >         ERR_print_errors_fp(stderr);
261.       }
262.   

crypto/err/err_prn.c:57:1: start of procedure ERR_print_errors_fp()
  55.   
  56.   #ifndef OPENSSL_NO_STDIO
  57. > void ERR_print_errors_fp(FILE *fp)
  58.   {
  59.       BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);

crypto/err/err_prn.c:59:5: 
  57.   void ERR_print_errors_fp(FILE *fp)
  58.   {
  59. >     BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);
  60.       if (bio == NULL)
  61.           return;

crypto/bio/bss_file.c:101:1: start of procedure BIO_new_fp()
    99.   }
    100.   
    101. > BIO *BIO_new_fp(FILE *stream, int close_flag)
    102.   {
    103.       BIO *ret;

crypto/bio/bss_file.c:105:9: 
    103.       BIO *ret;
    104.   
    105. >     if ((ret = BIO_new(BIO_s_file())) == NULL)
    106.           return (NULL);
    107.   

crypto/bio/bss_file.c:114:1: start of procedure BIO_s_file()
      112.   }
      113.   
      114. > const BIO_METHOD *BIO_s_file(void)
      115.   {
      116.       return (&methods_filep);

crypto/bio/bss_file.c:116:5: 
      114.   const BIO_METHOD *BIO_s_file(void)
      115.   {
      116. >     return (&methods_filep);
      117.   }
      118.   

crypto/bio/bss_file.c:117:1: return from a call to BIO_s_file
      115.   {
      116.       return (&methods_filep);
      117. > }
      118.   
      119.   static int file_new(BIO *bi)

crypto/bio/bss_file.c:105:9: Taking true branch
    103.       BIO *ret;
    104.   
    105.       if ((ret = BIO_new(BIO_s_file())) == NULL)
                   ^
    106.           return (NULL);
    107.   

crypto/bio/bss_file.c:106:9: 
    104.   
    105.       if ((ret = BIO_new(BIO_s_file())) == NULL)
    106. >         return (NULL);
    107.   
    108.       /* redundant flag, left for documentation purposes */

crypto/bio/bss_file.c:112:1: return from a call to BIO_new_fp
    110.       BIO_set_fp(ret, stream, close_flag);
    111.       return (ret);
    112. > }
    113.   
    114.   const BIO_METHOD *BIO_s_file(void)

crypto/err/err_prn.c:60:9: Taking true branch
  58.   {
  59.       BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);
  60.       if (bio == NULL)
                ^
  61.           return;
  62.   

crypto/err/err_prn.c:61:9: 
  59.       BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);
  60.       if (bio == NULL)
  61. >         return;
  62.   
  63.       ERR_print_errors_cb(print_bio, bio);

crypto/err/err_prn.c:65:1: return from a call to ERR_print_errors_fp
  63.       ERR_print_errors_cb(print_bio, bio);
  64.       BIO_free(bio);
  65. > }
  66.   #endif

test/evp_extra_test.c:263:5: 
261.       }
262.   
263. >     EVP_MD_CTX_free(md_ctx);
264.       EVP_MD_CTX_free(md_ctx_verify);
265.       EVP_PKEY_free(pkey);

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 test_EVP_DigestSignInit(void)
{
    int ret = 0;
    EVP_PKEY *pkey = NULL;
    unsigned char *sig = NULL;
    size_t sig_len = 0;
    EVP_MD_CTX *md_ctx, *md_ctx_verify;
    md_ctx = EVP_MD_CTX_new();
    md_ctx_verify = EVP_MD_CTX_new();
    if (md_ctx == NULL || md_ctx_verify == NULL)
        goto out;
    pkey = load_example_rsa_key();
    if (pkey == NULL ||
        !EVP_DigestSignInit(md_ctx, NULL, EVP_sha256(), NULL, pkey) ||
        !EVP_DigestSignUpdate(md_ctx, kMsg, sizeof(kMsg))) {
        goto out;
    }
    if (!EVP_DigestSignFinal(md_ctx, NULL, &sig_len)) {
        goto out;
    }
    if (sig_len != (size_t)EVP_PKEY_size(pkey)) {
        fprintf(stderr, "sig_len mismatch\n");
        goto out;
    }
    sig = OPENSSL_malloc(sig_len);
    if (sig == NULL || !EVP_DigestSignFinal(md_ctx, sig, &sig_len)) {
        goto out;
    }
    if (!EVP_DigestVerifyInit(md_ctx_verify, NULL, EVP_sha256(), NULL, pkey)
        || !EVP_DigestVerifyUpdate(md_ctx_verify, kMsg, sizeof(kMsg))
        || !EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len)) {
        goto out;
    }
    ret = 1;
 out:
    if (!ret) {
        ERR_print_errors_fp(stderr);
    }
    EVP_MD_CTX_free(md_ctx);
    EVP_MD_CTX_free(md_ctx_verify);
    EVP_PKEY_free(pkey);
    OPENSSL_free(sig);
    return ret;
}
['static int test_EVP_DigestSignInit(void)\n{\n    int ret = 0;\n    EVP_PKEY *pkey = NULL;\n    unsigned char *sig = NULL;\n    size_t sig_len = 0;\n    EVP_MD_CTX *md_ctx, *md_ctx_verify;\n    md_ctx = EVP_MD_CTX_new();\n    md_ctx_verify = EVP_MD_CTX_new();\n    if (md_ctx == NULL || md_ctx_verify == NULL)\n        goto out;\n    pkey = load_example_rsa_key();\n    if (pkey == NULL ||\n        !EVP_DigestSignInit(md_ctx, NULL, EVP_sha256(), NULL, pkey) ||\n        !EVP_DigestSignUpdate(md_ctx, kMsg, sizeof(kMsg))) {\n        goto out;\n    }\n    if (!EVP_DigestSignFinal(md_ctx, NULL, &sig_len)) {\n        goto out;\n    }\n    if (sig_len != (size_t)EVP_PKEY_size(pkey)) {\n        fprintf(stderr, "sig_len mismatch\\n");\n        goto out;\n    }\n    sig = OPENSSL_malloc(sig_len);\n    if (sig == NULL || !EVP_DigestSignFinal(md_ctx, sig, &sig_len)) {\n        goto out;\n    }\n    if (!EVP_DigestVerifyInit(md_ctx_verify, NULL, EVP_sha256(), NULL, pkey)\n        || !EVP_DigestVerifyUpdate(md_ctx_verify, kMsg, sizeof(kMsg))\n        || !EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len)) {\n        goto out;\n    }\n    ret = 1;\n out:\n    if (!ret) {\n        ERR_print_errors_fp(stderr);\n    }\n    EVP_MD_CTX_free(md_ctx);\n    EVP_MD_CTX_free(md_ctx_verify);\n    EVP_PKEY_free(pkey);\n    OPENSSL_free(sig);\n    return ret;\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}', 'void ERR_print_errors_fp(FILE *fp)\n{\n    BIO *bio = BIO_new_fp(fp, BIO_NOCLOSE);\n    if (bio == NULL)\n        return;\n    ERR_print_errors_cb(print_bio, bio);\n    BIO_free(bio);\n}', 'BIO *BIO_new_fp(FILE *stream, int close_flag)\n{\n    BIO *ret;\n    if ((ret = BIO_new(BIO_s_file())) == NULL)\n        return (NULL);\n    BIO_set_flags(ret, BIO_FLAGS_UPLINK);\n    BIO_set_fp(ret, stream, close_flag);\n    return (ret);\n}', 'const BIO_METHOD *BIO_s_file(void)\n{\n    return (&methods_filep);\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}']