crypto/evp/m_sigver.c:165: error: MEMORY_LEAK
  memory dynamically allocated to `tmp_ctx` by call to `EVP_MD_CTX_new()` at line 164, column 31 is not reachable after line 165, column 33.
Showing all 51 steps of the trace


crypto/evp/m_sigver.c:146:1: start of procedure EVP_DigestVerifyFinal()
144.   }
145.   
146. > int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
147.                             size_t siglen)
148.   {

crypto/evp/m_sigver.c:150:5: 
148.   {
149.       unsigned char md[EVP_MAX_MD_SIZE];
150. >     int r = 0;
151.       unsigned int mdlen = 0;
152.       int vctx = 0;

crypto/evp/m_sigver.c:151:5: 
149.       unsigned char md[EVP_MAX_MD_SIZE];
150.       int r = 0;
151. >     unsigned int mdlen = 0;
152.       int vctx = 0;
153.   

crypto/evp/m_sigver.c:152:5: 
150.       int r = 0;
151.       unsigned int mdlen = 0;
152. >     int vctx = 0;
153.   
154.       if (ctx->pctx->pmeth->verifyctx)

crypto/evp/m_sigver.c:154:9: Taking true branch
152.       int vctx = 0;
153.   
154.       if (ctx->pctx->pmeth->verifyctx)
               ^
155.           vctx = 1;
156.       else

crypto/evp/m_sigver.c:155:9: 
153.   
154.       if (ctx->pctx->pmeth->verifyctx)
155. >         vctx = 1;
156.       else
157.           vctx = 0;

crypto/evp/m_sigver.c:158:9: Taking false branch
156.       else
157.           vctx = 0;
158.       if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
               ^
159.           if (vctx) {
160.               r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx);

crypto/evp/m_sigver.c:164:9: 
162.               r = EVP_DigestFinal_ex(ctx, md, &mdlen);
163.       } else {
164. >         EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
165.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
166.               return -1;

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)

crypto/evp/m_sigver.c:165:13: Taking false branch
163.       } else {
164.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
165.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                   ^
166.               return -1;
167.           if (vctx) {

crypto/evp/m_sigver.c:165:33: 
163.       } else {
164.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
165. >         if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
166.               return -1;
167.           if (vctx) {

crypto/evp/digest.c:183:1: start of procedure EVP_MD_CTX_copy_ex()
  181.   }
  182.   
  183. > int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  184.   {
  185.       unsigned char *tmp_buf;

crypto/evp/digest.c:186:10: Taking false branch
  184.   {
  185.       unsigned char *tmp_buf;
  186.       if ((in == NULL) || (in->digest == NULL)) {
                  ^
  187.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  188.           return 0;

crypto/evp/digest.c:186:26: Taking false branch
  184.   {
  185.       unsigned char *tmp_buf;
  186.       if ((in == NULL) || (in->digest == NULL)) {
                                  ^
  187.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  188.           return 0;

crypto/evp/digest.c:192:9: Taking true branch
  190.   #ifndef OPENSSL_NO_ENGINE
  191.       /* Make sure it's safe to copy a digest context using an ENGINE */
  192.       if (in->engine && !ENGINE_init(in->engine)) {
                 ^
  193.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  194.           return 0;

crypto/evp/digest.c:192:24: 
  190.   #ifndef OPENSSL_NO_ENGINE
  191.       /* Make sure it's safe to copy a digest context using an ENGINE */
  192. >     if (in->engine && !ENGINE_init(in->engine)) {
  193.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  194.           return 0;

crypto/engine/eng_init.c:76:1: start of procedure ENGINE_init()
    74.   
    75.   /* The API (locked) version of "init" */
    76. > int ENGINE_init(ENGINE *e)
    77.   {
    78.       int ret;

crypto/engine/eng_init.c:79:9: Taking false branch
    77.   {
    78.       int ret;
    79.       if (e == NULL) {
                  ^
    80.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);
    81.           return 0;

crypto/engine/eng_init.c:83:10: 
    81.           return 0;
    82.       }
    83. >     if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
    84.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
    85.           return 0;

crypto/threads_pthread.c:104:1: start of procedure CRYPTO_THREAD_run_once()
      102.   }
      103.   
      104. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      105.   {
      106.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:106:9: Taking true branch
      104.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      105.   {
      106.       if (pthread_once(once, init) != 0)
                     ^
      107.           return 0;
      108.   

crypto/threads_pthread.c:107:9: 
      105.   {
      106.       if (pthread_once(once, init) != 0)
      107. >         return 0;
      108.   
      109.       return 1;

crypto/threads_pthread.c:110:1: return from a call to CRYPTO_THREAD_run_once
      108.   
      109.       return 1;
      110. > }
      111.   
      112.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/engine/eng_init.c:83:10: Condition is false
    81.           return 0;
    82.       }
    83.       if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
                   ^
    84.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
    85.           return 0;

crypto/engine/eng_init.c:83:10: Taking true branch
    81.           return 0;
    82.       }
    83.       if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
                   ^
    84.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
    85.           return 0;

crypto/engine/eng_init.c:84:9: Skipping ERR_put_error(): empty list of specs
    82.       }
    83.       if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
    84.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
                  ^
    85.           return 0;
    86.       }

crypto/engine/eng_init.c:85:9: 
    83.       if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
    84.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
    85. >         return 0;
    86.       }
    87.       CRYPTO_THREAD_write_lock(global_engine_lock);

crypto/engine/eng_init.c:91:1: return from a call to ENGINE_init
    89.       CRYPTO_THREAD_unlock(global_engine_lock);
    90.       return ret;
    91. > }
    92.   
    93.   /* The API (locked) version of "finish" */

crypto/evp/digest.c:192:24: Taking true branch
  190.   #ifndef OPENSSL_NO_ENGINE
  191.       /* Make sure it's safe to copy a digest context using an ENGINE */
  192.       if (in->engine && !ENGINE_init(in->engine)) {
                                ^
  193.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  194.           return 0;

crypto/evp/digest.c:193:9: Skipping ERR_put_error(): empty list of specs
  191.       /* Make sure it's safe to copy a digest context using an ENGINE */
  192.       if (in->engine && !ENGINE_init(in->engine)) {
  193.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
                 ^
  194.           return 0;
  195.       }

crypto/evp/digest.c:194:9: 
  192.       if (in->engine && !ENGINE_init(in->engine)) {
  193.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  194. >         return 0;
  195.       }
  196.   #endif

crypto/evp/digest.c:240:1: return from a call to EVP_MD_CTX_copy_ex
  238.   
  239.       return 1;
  240. > }
  241.   
  242.   int EVP_Digest(const void *data, size_t count,

crypto/evp/m_sigver.c:165:33: Taking true branch
163.       } else {
164.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
165.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                                       ^
166.               return -1;
167.           if (vctx) {

int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
                          size_t siglen)
{
    unsigned char md[EVP_MAX_MD_SIZE];
    int r = 0;
    unsigned int mdlen = 0;
    int vctx = 0;
    if (ctx->pctx->pmeth->verifyctx)
        vctx = 1;
    else
        vctx = 0;
    if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
        if (vctx) {
            r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx);
        } else
            r = EVP_DigestFinal_ex(ctx, md, &mdlen);
    } else {
        EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
        if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
            return -1;
        if (vctx) {
            r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx,
                                                sig, siglen, tmp_ctx);
        } else
            r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);
        EVP_MD_CTX_free(tmp_ctx);
    }
    if (vctx || !r)
        return r;
    return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);
}
['int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,\n                          size_t siglen)\n{\n    unsigned char md[EVP_MAX_MD_SIZE];\n    int r = 0;\n    unsigned int mdlen = 0;\n    int vctx = 0;\n    if (ctx->pctx->pmeth->verifyctx)\n        vctx = 1;\n    else\n        vctx = 0;\n    if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {\n        if (vctx) {\n            r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx);\n        } else\n            r = EVP_DigestFinal_ex(ctx, md, &mdlen);\n    } else {\n        EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();\n        if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))\n            return -1;\n        if (vctx) {\n            r = tmp_ctx->pctx->pmeth->verifyctx(tmp_ctx->pctx,\n                                                sig, siglen, tmp_ctx);\n        } else\n            r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);\n        EVP_MD_CTX_free(tmp_ctx);\n    }\n    if (vctx || !r)\n        return r;\n    return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen);\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 EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)\n{\n    unsigned char *tmp_buf;\n    if ((in == NULL) || (in->digest == NULL)) {\n        EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);\n        return 0;\n    }\n#ifndef OPENSSL_NO_ENGINE\n    if (in->engine && !ENGINE_init(in->engine)) {\n        EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);\n        return 0;\n    }\n#endif\n    if (out->digest == in->digest) {\n        tmp_buf = out->md_data;\n        EVP_MD_CTX_set_flags(out, EVP_MD_CTX_FLAG_REUSE);\n    } else\n        tmp_buf = NULL;\n    EVP_MD_CTX_reset(out);\n    memcpy(out, in, sizeof(*out));\n    out->md_data = NULL;\n    out->pctx = NULL;\n    if (in->md_data && out->digest->ctx_size) {\n        if (tmp_buf)\n            out->md_data = tmp_buf;\n        else {\n            out->md_data = OPENSSL_malloc(out->digest->ctx_size);\n            if (out->md_data == NULL) {\n                EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_MALLOC_FAILURE);\n                return 0;\n            }\n        }\n        memcpy(out->md_data, in->md_data, out->digest->ctx_size);\n    }\n    out->update = in->update;\n    if (in->pctx) {\n        out->pctx = EVP_PKEY_CTX_dup(in->pctx);\n        if (!out->pctx) {\n            EVP_MD_CTX_reset(out);\n            return 0;\n        }\n    }\n    if (out->digest->copy)\n        return out->digest->copy(out, in);\n    return 1;\n}', 'int ENGINE_init(ENGINE *e)\n{\n    int ret;\n    if (e == NULL) {\n        ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {\n        ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    CRYPTO_THREAD_write_lock(global_engine_lock);\n    ret = engine_unlocked_init(e);\n    CRYPTO_THREAD_unlock(global_engine_lock);\n    return ret;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}']