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


crypto/evp/m_sigver.c:187:1: start of procedure EVP_DigestVerifyFinal()
185.   }
186.   
187. > int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
188.                             size_t siglen)
189.   {

crypto/evp/m_sigver.c:191:5: 
189.   {
190.       unsigned char md[EVP_MAX_MD_SIZE];
191. >     int r = 0;
192.       unsigned int mdlen = 0;
193.       int vctx = 0;

crypto/evp/m_sigver.c:192:5: 
190.       unsigned char md[EVP_MAX_MD_SIZE];
191.       int r = 0;
192. >     unsigned int mdlen = 0;
193.       int vctx = 0;
194.   

crypto/evp/m_sigver.c:193:5: 
191.       int r = 0;
192.       unsigned int mdlen = 0;
193. >     int vctx = 0;
194.   
195.       if (ctx->pctx->pmeth->verifyctx)

crypto/evp/m_sigver.c:195:9: Taking true branch
193.       int vctx = 0;
194.   
195.       if (ctx->pctx->pmeth->verifyctx)
               ^
196.           vctx = 1;
197.       else

crypto/evp/m_sigver.c:196:9: 
194.   
195.       if (ctx->pctx->pmeth->verifyctx)
196. >         vctx = 1;
197.       else
198.           vctx = 0;

crypto/evp/m_sigver.c:199:9: Taking false branch
197.       else
198.           vctx = 0;
199.       if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
               ^
200.           if (vctx) {
201.               r = ctx->pctx->pmeth->verifyctx(ctx->pctx, sig, siglen, ctx);

crypto/evp/m_sigver.c:205:9: 
203.               r = EVP_DigestFinal_ex(ctx, md, &mdlen);
204.       } else {
205. >         EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
206.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
207.               return -1;

crypto/evp/digest.c:147:1: start of procedure EVP_MD_CTX_new()
  145.   }
  146.   
  147. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  148.   {
  149.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:149:5: 
  147.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  148.   {
  149. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  150.   }
  151.   

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:151:9: 
    149.   
    150.       if (ret != NULL)
    151. >         memset(ret, 0, num);
    152.       return ret;
    153.   }

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:150:1: return from a call to EVP_MD_CTX_new
  148.   {
  149.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  150. > }
  151.   
  152.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/evp/m_sigver.c:206:13: Taking false branch
204.       } else {
205.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
206.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                   ^
207.               return -1;
208.           if (vctx) {

crypto/evp/m_sigver.c:206:33: 
204.       } else {
205.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
206. >         if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
207.               return -1;
208.           if (vctx) {

crypto/evp/digest.c:286:1: start of procedure EVP_MD_CTX_copy_ex()
  284.   }
  285.   
  286. > int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  287.   {
  288.       unsigned char *tmp_buf;

crypto/evp/digest.c:289:10: Taking false branch
  287.   {
  288.       unsigned char *tmp_buf;
  289.       if ((in == NULL) || (in->digest == NULL)) {
                  ^
  290.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  291.           return 0;

crypto/evp/digest.c:289:26: Taking true branch
  287.   {
  288.       unsigned char *tmp_buf;
  289.       if ((in == NULL) || (in->digest == NULL)) {
                                  ^
  290.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  291.           return 0;

crypto/evp/digest.c:290:9: Skipping ERR_put_error(): empty list of specs
  288.       unsigned char *tmp_buf;
  289.       if ((in == NULL) || (in->digest == NULL)) {
  290.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
                 ^
  291.           return 0;
  292.       }

crypto/evp/digest.c:291:9: 
  289.       if ((in == NULL) || (in->digest == NULL)) {
  290.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  291. >         return 0;
  292.       }
  293.   #ifndef OPENSSL_NO_ENGINE

crypto/evp/digest.c:343:1: return from a call to EVP_MD_CTX_copy_ex
  341.   
  342.       return 1;
  343. > }
  344.   
  345.   int EVP_Digest(const void *data, size_t count,

crypto/evp/m_sigver.c:206:33: Taking true branch
204.       } else {
205.           EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
206.           if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
                                       ^
207.               return -1;
208.           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}']