apps/pkeyutl.c:709: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 657, column 17 is not reachable after line 709, column 5.
Showing all 84 steps of the trace


apps/pkeyutl.c:647:1: start of procedure do_raw_keyop()
645.   #define TBUF_MAXSIZE 2048
646.   
647. > static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx,
648.                           const EVP_MD *md, EVP_PKEY *pkey, BIO *in,
649.                           unsigned char *sig, int siglen,

apps/pkeyutl.c:652:5: 
650.                           unsigned char **out, size_t *poutlen)
651.   {
652. >     int rv = 0;
653.       EVP_MD_CTX *mctx = NULL;
654.       unsigned char tbuf[TBUF_MAXSIZE];

apps/pkeyutl.c:653:5: 
651.   {
652.       int rv = 0;
653. >     EVP_MD_CTX *mctx = NULL;
654.       unsigned char tbuf[TBUF_MAXSIZE];
655.       int tbuf_len = 0;

apps/pkeyutl.c:655:5: 
653.       EVP_MD_CTX *mctx = NULL;
654.       unsigned char tbuf[TBUF_MAXSIZE];
655. >     int tbuf_len = 0;
656.   
657.       if ((mctx = EVP_MD_CTX_new()) == NULL) {

apps/pkeyutl.c:657:9: 
655.       int tbuf_len = 0;
656.   
657. >     if ((mctx = EVP_MD_CTX_new()) == NULL) {
658.           BIO_printf(bio_err, "Error: out of memory\n");
659.           return rv;

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_new()
  47.   }
  48.   
  49. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  50.   {
  51.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:51:5: 
  49.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  50.   {
  51. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  52.   }
  53.   

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
    226.   }
    227.   
    228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230. >     void *ret = CRYPTO_malloc(num, file, line);
    231.   
    232.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
      190.   #endif
      191.   
      192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194.       void *ret = NULL;

crypto/mem.c:194:5: 
      192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194. >     void *ret = NULL;
      195.   
      196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
      195.   
      196.       INCREMENT(malloc_count);
      197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      198.           return malloc_impl(num, file, line);
      199.   

crypto/mem.c:200:9: Taking false branch
      198.           return malloc_impl(num, file, line);
      199.   
      200.       if (num == 0)
                     ^
      201.           return NULL;
      202.   

crypto/mem.c:204:9: Taking true branch
      202.   
      203.       FAILTEST();
      204.       if (allow_customize) {
                     ^
      205.           /*
      206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
      208.            * allocation.
      209.            */
      210. >         allow_customize = 0;
      211.       }
      212.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:221:5: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:221:19: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:222:5: 
      220.   #else
      221.       (void)(file); (void)(line);
      222. >     ret = malloc(num);
      223.   #endif
      224.   

crypto/mem.c:225:5: 
      223.   #endif
      224.   
      225. >     return ret;
      226.   }
      227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
      224.   
      225.       return ret;
      226. > }
      227.   
      228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
    231.   
    232.       FAILTEST();
    233.       if (ret != NULL)
                   ^
    234.           memset(ret, 0, num);
    235.       return ret;

crypto/mem.c:234:9: 
    232.       FAILTEST();
    233.       if (ret != NULL)
    234. >         memset(ret, 0, num);
    235.       return ret;
    236.   }

crypto/mem.c:235:5: 
    233.       if (ret != NULL)
    234.           memset(ret, 0, num);
    235. >     return ret;
    236.   }
    237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
    234.           memset(ret, 0, num);
    235.       return ret;
    236. > }
    237.   
    238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:52:1: return from a call to EVP_MD_CTX_new
  50.   {
  51.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  52. > }
  53.   
  54.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

apps/pkeyutl.c:657:9: Taking false branch
655.       int tbuf_len = 0;
656.   
657.       if ((mctx = EVP_MD_CTX_new()) == NULL) {
               ^
658.           BIO_printf(bio_err, "Error: out of memory\n");
659.           return rv;

apps/pkeyutl.c:661:5: 
659.           return rv;
660.       }
661. >     EVP_MD_CTX_set_pkey_ctx(mctx, ctx);
662.   
663.       switch(pkey_op) {

crypto/evp/evp_lib.c:463:1: start of procedure EVP_MD_CTX_set_pkey_ctx()
  461.   }
  462.   
  463. > void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx)
  464.   {
  465.       /*

crypto/evp/evp_lib.c:469:10: 
  467.        * we have to deal with the cleanup job here.
  468.        */
  469. >     if (!EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX))
  470.           EVP_PKEY_CTX_free(ctx->pctx);
  471.   

crypto/evp/evp_lib.c:510:1: start of procedure EVP_MD_CTX_test_flags()
    508.   }
    509.   
    510. > int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags)
    511.   {
    512.       return (ctx->flags & flags);

crypto/evp/evp_lib.c:512:5: 
    510.   int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags)
    511.   {
    512. >     return (ctx->flags & flags);
    513.   }
    514.   

crypto/evp/evp_lib.c:513:1: return from a call to EVP_MD_CTX_test_flags
    511.   {
    512.       return (ctx->flags & flags);
    513. > }
    514.   
    515.   void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags)

crypto/evp/evp_lib.c:469:10: Taking true branch
  467.        * we have to deal with the cleanup job here.
  468.        */
  469.       if (!EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX))
                  ^
  470.           EVP_PKEY_CTX_free(ctx->pctx);
  471.   

crypto/evp/evp_lib.c:470:9: 
  468.        */
  469.       if (!EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX))
  470. >         EVP_PKEY_CTX_free(ctx->pctx);
  471.   
  472.       ctx->pctx = pctx;

crypto/evp/pmeth_lib.c:352:1: start of procedure EVP_PKEY_CTX_free()
    350.   }
    351.   
    352. > void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
    353.   {
    354.       if (ctx == NULL)

crypto/evp/pmeth_lib.c:354:9: Taking false branch
    352.   void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
    353.   {
    354.       if (ctx == NULL)
                   ^
    355.           return;
    356.       if (ctx->pmeth && ctx->pmeth->cleanup)

crypto/evp/pmeth_lib.c:356:9: Taking true branch
    354.       if (ctx == NULL)
    355.           return;
    356.       if (ctx->pmeth && ctx->pmeth->cleanup)
                   ^
    357.           ctx->pmeth->cleanup(ctx);
    358.       EVP_PKEY_free(ctx->pkey);

crypto/evp/pmeth_lib.c:356:23: Taking true branch
    354.       if (ctx == NULL)
    355.           return;
    356.       if (ctx->pmeth && ctx->pmeth->cleanup)
                                 ^
    357.           ctx->pmeth->cleanup(ctx);
    358.       EVP_PKEY_free(ctx->pkey);

crypto/evp/pmeth_lib.c:357:9: Skipping __function_pointer__(): unresolved function pointer
    355.           return;
    356.       if (ctx->pmeth && ctx->pmeth->cleanup)
    357.           ctx->pmeth->cleanup(ctx);
                   ^
    358.       EVP_PKEY_free(ctx->pkey);
    359.       EVP_PKEY_free(ctx->peerkey);

crypto/evp/pmeth_lib.c:358:5: 
    356.       if (ctx->pmeth && ctx->pmeth->cleanup)
    357.           ctx->pmeth->cleanup(ctx);
    358. >     EVP_PKEY_free(ctx->pkey);
    359.       EVP_PKEY_free(ctx->peerkey);
    360.   #ifndef OPENSSL_NO_ENGINE

crypto/evp/p_lib.c:590:1: start of procedure EVP_PKEY_free()
      588.   }
      589.   
      590. > void EVP_PKEY_free(EVP_PKEY *x)
      591.   {
      592.       int i;

crypto/evp/p_lib.c:594:9: Taking true branch
      592.       int i;
      593.   
      594.       if (x == NULL)
                     ^
      595.           return;
      596.   

crypto/evp/p_lib.c:595:9: 
      593.   
      594.       if (x == NULL)
      595. >         return;
      596.   
      597.       CRYPTO_DOWN_REF(&x->references, &i, x->lock);

crypto/evp/p_lib.c:606:1: return from a call to EVP_PKEY_free
      604.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
      605.       OPENSSL_free(x);
      606. > }
      607.   
      608.   static void EVP_PKEY_free_it(EVP_PKEY *x)

crypto/evp/pmeth_lib.c:359:5: 
    357.           ctx->pmeth->cleanup(ctx);
    358.       EVP_PKEY_free(ctx->pkey);
    359. >     EVP_PKEY_free(ctx->peerkey);
    360.   #ifndef OPENSSL_NO_ENGINE
    361.       ENGINE_finish(ctx->engine);

crypto/evp/p_lib.c:590:1: start of procedure EVP_PKEY_free()
      588.   }
      589.   
      590. > void EVP_PKEY_free(EVP_PKEY *x)
      591.   {
      592.       int i;

crypto/evp/p_lib.c:594:9: Taking true branch
      592.       int i;
      593.   
      594.       if (x == NULL)
                     ^
      595.           return;
      596.   

crypto/evp/p_lib.c:595:9: 
      593.   
      594.       if (x == NULL)
      595. >         return;
      596.   
      597.       CRYPTO_DOWN_REF(&x->references, &i, x->lock);

crypto/evp/p_lib.c:606:1: return from a call to EVP_PKEY_free
      604.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
      605.       OPENSSL_free(x);
      606. > }
      607.   
      608.   static void EVP_PKEY_free_it(EVP_PKEY *x)

crypto/evp/pmeth_lib.c:361:5: 
    359.       EVP_PKEY_free(ctx->peerkey);
    360.   #ifndef OPENSSL_NO_ENGINE
    361. >     ENGINE_finish(ctx->engine);
    362.   #endif
    363.       OPENSSL_free(ctx);

crypto/engine/eng_init.c:95:1: start of procedure ENGINE_finish()
      93.   
      94.   /* The API (locked) version of "finish" */
      95. > int ENGINE_finish(ENGINE *e)
      96.   {
      97.       int to_return = 1;

crypto/engine/eng_init.c:97:5: 
      95.   int ENGINE_finish(ENGINE *e)
      96.   {
      97. >     int to_return = 1;
      98.   
      99.       if (e == NULL)

crypto/engine/eng_init.c:99:9: Taking true branch
      97.       int to_return = 1;
      98.   
      99.       if (e == NULL)
                     ^
      100.           return 1;
      101.       CRYPTO_THREAD_write_lock(global_engine_lock);

crypto/engine/eng_init.c:100:9: 
      98.   
      99.       if (e == NULL)
      100. >         return 1;
      101.       CRYPTO_THREAD_write_lock(global_engine_lock);
      102.       to_return = engine_unlocked_finish(e, 1);

crypto/engine/eng_init.c:109:1: return from a call to ENGINE_finish
      107.       }
      108.       return to_return;
      109. > }

crypto/evp/pmeth_lib.c:363:5: 
    361.       ENGINE_finish(ctx->engine);
    362.   #endif
    363. >     OPENSSL_free(ctx);
    364.   }
    365.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
      293.   }
      294.   
      295. > void CRYPTO_free(void *str, const char *file, int line)
      296.   {
      297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking false branch
      296.   {
      297.       INCREMENT(free_count);
      298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                     ^
      299.           free_impl(str, file, line);
      300.           return;

crypto/mem.c:312:5: 
      310.       }
      311.   #else
      312. >     free(str);
      313.   #endif
      314.   }

crypto/mem.c:314:1: return from a call to CRYPTO_free
      312.       free(str);
      313.   #endif
      314. > }
      315.   
      316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/pmeth_lib.c:364:1: return from a call to EVP_PKEY_CTX_free
    362.   #endif
    363.       OPENSSL_free(ctx);
    364. > }
    365.   
    366.   int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,

crypto/evp/evp_lib.c:472:5: 
  470.           EVP_PKEY_CTX_free(ctx->pctx);
  471.   
  472. >     ctx->pctx = pctx;
  473.   
  474.       if (pctx != NULL) {

crypto/evp/evp_lib.c:474:9: Taking true branch
  472.       ctx->pctx = pctx;
  473.   
  474.       if (pctx != NULL) {
                 ^
  475.           /* make sure pctx is not freed when destroying EVP_MD_CTX */
  476.           EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);

crypto/evp/evp_lib.c:476:9: 
  474.       if (pctx != NULL) {
  475.           /* make sure pctx is not freed when destroying EVP_MD_CTX */
  476. >         EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);
  477.       } else {
  478.           EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);

crypto/evp/evp_lib.c:500:1: start of procedure EVP_MD_CTX_set_flags()
    498.   }
    499.   
    500. > void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
    501.   {
    502.       ctx->flags |= flags;

crypto/evp/evp_lib.c:502:5: 
    500.   void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
    501.   {
    502. >     ctx->flags |= flags;
    503.   }
    504.   

crypto/evp/evp_lib.c:503:1: return from a call to EVP_MD_CTX_set_flags
    501.   {
    502.       ctx->flags |= flags;
    503. > }
    504.   
    505.   void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags)

crypto/evp/evp_lib.c:474:5: 
  472.       ctx->pctx = pctx;
  473.   
  474. >     if (pctx != NULL) {
  475.           /* make sure pctx is not freed when destroying EVP_MD_CTX */
  476.           EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);

crypto/evp/evp_lib.c:480:1: return from a call to EVP_MD_CTX_set_pkey_ctx
  478.           EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);
  479.       }
  480. > }
  481.   
  482.   void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx)

apps/pkeyutl.c:663:5: 
661.       EVP_MD_CTX_set_pkey_ctx(mctx, ctx);
662.   
663. >     switch(pkey_op) {
664.       case EVP_PKEY_OP_VERIFY:
665.           if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1)

apps/pkeyutl.c:664:5: Switch condition is false. Skipping switch case
662.   
663.       switch(pkey_op) {
664.       case EVP_PKEY_OP_VERIFY:
           ^
665.           if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1)
666.               goto end;

apps/pkeyutl.c:683:5: Switch condition is false. Skipping switch case
681.           rv = EVP_DigestVerifyFinal(mctx, sig, (size_t)siglen);
682.           break;
683.       case EVP_PKEY_OP_SIGN:
           ^
684.           if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1)
685.               goto end;

apps/pkeyutl.c:708:2: 
706.       }
707.   
708. >  end:
709.       EVP_MD_CTX_free(mctx);
710.       return rv;

apps/pkeyutl.c:709:5: 
707.   
708.    end:
709. >     EVP_MD_CTX_free(mctx);
710.       return rv;
711.   }

crypto/evp/digest.c:54:1: start of procedure EVP_MD_CTX_free()
  52.   }
  53.   
  54. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  55.   {
  56.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:56:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  54.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  55.   {
  56.       EVP_MD_CTX_reset(ctx);
            ^
  57.       OPENSSL_free(ctx);
  58.   }

crypto/evp/digest.c:57:5: 
  55.   {
  56.       EVP_MD_CTX_reset(ctx);
  57. >     OPENSSL_free(ctx);
  58.   }
  59.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:58:1: return from a call to EVP_MD_CTX_free
  56.       EVP_MD_CTX_reset(ctx);
  57.       OPENSSL_free(ctx);
  58. > }
  59.   
  60.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
