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


crypto/evp/m_sigver.c:138:1: start of procedure EVP_DigestVerifyFinal()
136.   }
137.   
138. > int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
139.                             size_t siglen)
140.   {

crypto/evp/m_sigver.c:142:5: 
140.   {
141.       unsigned char md[EVP_MAX_MD_SIZE];
142. >     int r = 0;
143.       unsigned int mdlen = 0;
144.       int vctx = 0;

crypto/evp/m_sigver.c:143:5: 
141.       unsigned char md[EVP_MAX_MD_SIZE];
142.       int r = 0;
143. >     unsigned int mdlen = 0;
144.       int vctx = 0;
145.   

crypto/evp/m_sigver.c:144:5: 
142.       int r = 0;
143.       unsigned int mdlen = 0;
144. >     int vctx = 0;
145.   
146.       if (ctx->pctx->pmeth->verifyctx)

crypto/evp/m_sigver.c:146:9: Taking true branch
144.       int vctx = 0;
145.   
146.       if (ctx->pctx->pmeth->verifyctx)
               ^
147.           vctx = 1;
148.       else

crypto/evp/m_sigver.c:147:9: 
145.   
146.       if (ctx->pctx->pmeth->verifyctx)
147. >         vctx = 1;
148.       else
149.           vctx = 0;

crypto/evp/m_sigver.c:150:9: Taking false branch
148.       else
149.           vctx = 0;
150.       if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
               ^
151.           if (vctx) {
152.               r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx);

crypto/evp/m_sigver.c:156:9: 
154.               r = EVP_DigestFinal_ex(ctx, md, &mdlen);
155.       } else {
156. >         EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
157.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
158.               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:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   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:157:13: Taking false branch
155.       } else {
156.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
157.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                   ^
158.               return -1;
159.           if (vctx) {

crypto/evp/m_sigver.c:157:33: 
155.       } else {
156.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
157. >         if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
158.               return -1;
159.           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 true 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:187:9: Skipping ERR_put_error(): empty list of specs
  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;
  189.       }

crypto/evp/digest.c:188:9: 
  186.       if ((in == NULL) || (in->digest == NULL)) {
  187.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  188. >         return 0;
  189.       }
  190.   #ifndef OPENSSL_NO_ENGINE

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:157:33: Taking true branch
155.       } else {
156.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
157.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                                       ^
158.               return -1;
159.           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    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    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}']