crypto/evp/m_sigver.c:129: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 125, column 35 is not reachable after line 129, column 17.
Showing all 65 steps of the trace


crypto/evp/m_sigver.c:93:1: start of procedure EVP_DigestSignFinal()
91.   }
92.   
93. > int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
94.                           size_t *siglen)
95.   {

crypto/evp/m_sigver.c:96:5: 
94.                           size_t *siglen)
95.   {
96. >     int sctx = 0, r = 0;
97.       EVP_PKEY_CTX *pctx = ctx->pctx;
98.       if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) {

crypto/evp/m_sigver.c:97:5: 
95.   {
96.       int sctx = 0, r = 0;
97. >     EVP_PKEY_CTX *pctx = ctx->pctx;
98.       if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) {
99.           if (!sigret)

crypto/evp/m_sigver.c:98:9: Taking false branch
96.       int sctx = 0, r = 0;
97.       EVP_PKEY_CTX *pctx = ctx->pctx;
98.       if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) {
               ^
99.           if (!sigret)
100.               return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);

crypto/evp/m_sigver.c:112:9: Taking true branch
110.           return r;
111.       }
112.       if (pctx->pmeth->signctx)
               ^
113.           sctx = 1;
114.       else

crypto/evp/m_sigver.c:113:9: 
111.       }
112.       if (pctx->pmeth->signctx)
113. >         sctx = 1;
114.       else
115.           sctx = 0;

crypto/evp/m_sigver.c:116:9: Taking true branch
114.       else
115.           sctx = 0;
116.       if (sigret) {
               ^
117.           unsigned char md[EVP_MAX_MD_SIZE];
118.           unsigned int mdlen = 0;

crypto/evp/m_sigver.c:118:9: 
116.       if (sigret) {
117.           unsigned char md[EVP_MAX_MD_SIZE];
118. >         unsigned int mdlen = 0;
119.           if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
120.               if (sctx)

crypto/evp/m_sigver.c:119:13: Taking false branch
117.           unsigned char md[EVP_MAX_MD_SIZE];
118.           unsigned int mdlen = 0;
119.           if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
                   ^
120.               if (sctx)
121.                   r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx);

crypto/evp/m_sigver.c:125:13: 
123.                   r = EVP_DigestFinal_ex(ctx, md, &mdlen);
124.           } else {
125. >             EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
126.               if (tmp_ctx == NULL)
127.                   return 0;

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: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: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:126:17: Taking false branch
124.           } else {
125.               EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
126.               if (tmp_ctx == NULL)
                       ^
127.                   return 0;
128.               if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {

crypto/evp/m_sigver.c:128:18: 
126.               if (tmp_ctx == NULL)
127.                   return 0;
128. >             if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
129.                   EVP_MD_CTX_free(tmp_ctx);
130.                   return 0;

crypto/evp/digest.c:204:1: start of procedure EVP_MD_CTX_copy_ex()
  202.   }
  203.   
  204. > int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  205.   {
  206.       unsigned char *tmp_buf;

crypto/evp/digest.c:207:10: Taking false branch
  205.   {
  206.       unsigned char *tmp_buf;
  207.       if ((in == NULL) || (in->digest == NULL)) {
                  ^
  208.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  209.           return 0;

crypto/evp/digest.c:207:26: Taking false branch
  205.   {
  206.       unsigned char *tmp_buf;
  207.       if ((in == NULL) || (in->digest == NULL)) {
                                  ^
  208.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);
  209.           return 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/evp/digest.c:215:9: 
  213.       if (in->engine && !ENGINE_init(in->engine)) {
  214.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  215. >         return 0;
  216.       }
  217.   #endif

crypto/evp/digest.c:261:1: return from a call to EVP_MD_CTX_copy_ex
  259.   
  260.       return 1;
  261. > }
  262.   
  263.   int EVP_Digest(const void *data, size_t count,

crypto/evp/m_sigver.c:128:18: Taking true branch
126.               if (tmp_ctx == NULL)
127.                   return 0;
128.               if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
                        ^
129.                   EVP_MD_CTX_free(tmp_ctx);
130.                   return 0;

crypto/evp/m_sigver.c:129:17: 
127.                   return 0;
128.               if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
129. >                 EVP_MD_CTX_free(tmp_ctx);
130.                   return 0;
131.               }

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

int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
                        size_t *siglen)
{
    int sctx = 0, r = 0;
    EVP_PKEY_CTX *pctx = ctx->pctx;
    if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) {
        if (!sigret)
            return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);
        if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE)
            r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx);
        else {
            EVP_PKEY_CTX *dctx = EVP_PKEY_CTX_dup(ctx->pctx);
            if (!dctx)
                return 0;
            r = dctx->pmeth->signctx(dctx, sigret, siglen, ctx);
            EVP_PKEY_CTX_free(dctx);
        }
        return r;
    }
    if (pctx->pmeth->signctx)
        sctx = 1;
    else
        sctx = 0;
    if (sigret) {
        unsigned char md[EVP_MAX_MD_SIZE];
        unsigned int mdlen = 0;
        if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {
            if (sctx)
                r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx);
            else
                r = EVP_DigestFinal_ex(ctx, md, &mdlen);
        } else {
            EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
            if (tmp_ctx == NULL)
                return 0;
            if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {
                EVP_MD_CTX_free(tmp_ctx);
                return 0;
            }
            if (sctx)
                r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx,
                                                  sigret, siglen, tmp_ctx);
            else
                r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);
            EVP_MD_CTX_free(tmp_ctx);
        }
        if (sctx || !r)
            return r;
        if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0)
            return 0;
    } else {
        if (sctx) {
            if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0)
                return 0;
        } else {
            int s = EVP_MD_size(ctx->digest);
            if (s < 0 || EVP_PKEY_sign(pctx, sigret, siglen, NULL, s) <= 0)
                return 0;
        }
    }
    return 1;
}
['int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                        size_t *siglen)\n{\n    int sctx = 0, r = 0;\n    EVP_PKEY_CTX *pctx = ctx->pctx;\n    if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) {\n        if (!sigret)\n            return pctx->pmeth->signctx(pctx, sigret, siglen, ctx);\n        if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE)\n            r = pctx->pmeth->signctx(pctx, sigret, siglen, ctx);\n        else {\n            EVP_PKEY_CTX *dctx = EVP_PKEY_CTX_dup(ctx->pctx);\n            if (!dctx)\n                return 0;\n            r = dctx->pmeth->signctx(dctx, sigret, siglen, ctx);\n            EVP_PKEY_CTX_free(dctx);\n        }\n        return r;\n    }\n    if (pctx->pmeth->signctx)\n        sctx = 1;\n    else\n        sctx = 0;\n    if (sigret) {\n        unsigned char md[EVP_MAX_MD_SIZE];\n        unsigned int mdlen = 0;\n        if (ctx->flags & EVP_MD_CTX_FLAG_FINALISE) {\n            if (sctx)\n                r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, 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)\n                return 0;\n            if (!EVP_MD_CTX_copy_ex(tmp_ctx, ctx)) {\n                EVP_MD_CTX_free(tmp_ctx);\n                return 0;\n            }\n            if (sctx)\n                r = tmp_ctx->pctx->pmeth->signctx(tmp_ctx->pctx,\n                                                  sigret, siglen, tmp_ctx);\n            else\n                r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);\n            EVP_MD_CTX_free(tmp_ctx);\n        }\n        if (sctx || !r)\n            return r;\n        if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0)\n            return 0;\n    } else {\n        if (sctx) {\n            if (pctx->pmeth->signctx(pctx, sigret, siglen, ctx) <= 0)\n                return 0;\n        } else {\n            int s = EVP_MD_size(ctx->digest);\n            if (s < 0 || EVP_PKEY_sign(pctx, sigret, siglen, NULL, s) <= 0)\n                return 0;\n        }\n    }\n    return 1;\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    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\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    (void)(file); (void)(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}', '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    INCREMENT(free_count);\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}']