ssl/ssl_lib.c:3647: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 3638, column 11 is not reachable after line 3647, column 5.
Showing all 86 steps of the trace


ssl/ssl_lib.c:3629:1: start of procedure ssl_handshake_hash()
3627.   
3628.   /* Retrieve handshake hashes */
3629. > int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)
3630.   {
3631.       EVP_MD_CTX *ctx = NULL;

ssl/ssl_lib.c:3631:5: 
3629.   int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)
3630.   {
3631. >     EVP_MD_CTX *ctx = NULL;
3632.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3633.       int ret = EVP_MD_CTX_size(hdgst);

ssl/ssl_lib.c:3632:5: 
3630.   {
3631.       EVP_MD_CTX *ctx = NULL;
3632. >     EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3633.       int ret = EVP_MD_CTX_size(hdgst);
3634.       if (ret < 0 || ret > outlen) {

ssl/ssl_lib.c:3633:5: 
3631.       EVP_MD_CTX *ctx = NULL;
3632.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3633. >     int ret = EVP_MD_CTX_size(hdgst);
3634.       if (ret < 0 || ret > outlen) {
3635.           ret = 0;

crypto/evp/evp_lib.c:477:1: start of procedure EVP_MD_CTX_md()
  475.   }
  476.   
  477. > const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
  478.   {
  479.       if (!ctx)

crypto/evp/evp_lib.c:479:10: Taking false branch
  477.   const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
  478.   {
  479.       if (!ctx)
                  ^
  480.           return NULL;
  481.       return ctx->digest;

crypto/evp/evp_lib.c:481:5: 
  479.       if (!ctx)
  480.           return NULL;
  481. >     return ctx->digest;
  482.   }
  483.   

crypto/evp/evp_lib.c:482:1: return from a call to EVP_MD_CTX_md
  480.           return NULL;
  481.       return ctx->digest;
  482. > }
  483.   
  484.   EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx)

crypto/evp/evp_lib.c:339:1: start of procedure EVP_MD_size()
  337.   }
  338.   
  339. > int EVP_MD_size(const EVP_MD *md)
  340.   {
  341.       if (!md) {

crypto/evp/evp_lib.c:341:10: Taking false branch
  339.   int EVP_MD_size(const EVP_MD *md)
  340.   {
  341.       if (!md) {
                  ^
  342.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  343.           return -1;

crypto/evp/evp_lib.c:345:5: 
  343.           return -1;
  344.       }
  345. >     return md->md_size;
  346.   }
  347.   

crypto/evp/evp_lib.c:346:1: return from a call to EVP_MD_size
  344.       }
  345.       return md->md_size;
  346. > }
  347.   
  348.   unsigned long EVP_MD_flags(const EVP_MD *md)

ssl/ssl_lib.c:3634:9: Taking false branch
3632.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3633.       int ret = EVP_MD_CTX_size(hdgst);
3634.       if (ret < 0 || ret > outlen) {
                ^
3635.           ret = 0;
3636.           goto err;

ssl/ssl_lib.c:3634:20: Taking false branch
3632.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3633.       int ret = EVP_MD_CTX_size(hdgst);
3634.       if (ret < 0 || ret > outlen) {
                           ^
3635.           ret = 0;
3636.           goto err;

ssl/ssl_lib.c:3638:5: 
3636.           goto err;
3637.       }
3638. >     ctx = EVP_MD_CTX_new();
3639.       if (ctx == NULL) {
3640.           ret = 0;

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)

ssl/ssl_lib.c:3639:9: Taking false branch
3637.       }
3638.       ctx = EVP_MD_CTX_new();
3639.       if (ctx == NULL) {
                ^
3640.           ret = 0;
3641.           goto err;

ssl/ssl_lib.c:3643:10: 
3641.           goto err;
3642.       }
3643. >     if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
3644.           || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
3645.           ret = 0;

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 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:295:9: Taking true branch
  293.   #ifndef OPENSSL_NO_ENGINE
  294.       /* Make sure it's safe to copy a digest context using an ENGINE */
  295.       if (in->engine && !ENGINE_init(in->engine)) {
                 ^
  296.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  297.           return 0;

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

crypto/engine/eng_init.c:121:1: start of procedure ENGINE_init()
    119.   
    120.   /* The API (locked) version of "init" */
    121. > int ENGINE_init(ENGINE *e)
    122.   {
    123.       int ret;

crypto/engine/eng_init.c:124:9: Taking false branch
    122.   {
    123.       int ret;
    124.       if (e == NULL) {
                   ^
    125.           ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);
    126.           return 0;

crypto/engine/eng_init.c:128:5: 
    126.           return 0;
    127.       }
    128. >     CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
    129.       ret = engine_unlocked_init(e);
    130.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking true branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:453:9: Skipping __function_pointer__(): unresolved function pointer
      451.           }
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
                     ^
      454.   }
      455.   

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/engine/eng_init.c:129:5: 
    127.       }
    128.       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
    129. >     ret = engine_unlocked_init(e);
    130.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    131.       return ret;

crypto/engine/eng_init.c:61:1: start of procedure engine_unlocked_init()
      59.    * it's already in use). This version is only used internally.
      60.    */
      61. > int engine_unlocked_init(ENGINE *e)
      62.   {
      63.       int to_return = 1;

crypto/engine/eng_init.c:63:5: 
      61.   int engine_unlocked_init(ENGINE *e)
      62.   {
      63. >     int to_return = 1;
      64.   
      65.       if ((e->funct_ref == 0) && e->init)

crypto/engine/eng_init.c:65:10: Taking true branch
      63.       int to_return = 1;
      64.   
      65.       if ((e->funct_ref == 0) && e->init)
                     ^
      66.           /*
      67.            * This is the first functional reference and the engine requires

crypto/engine/eng_init.c:65:32: Taking true branch
      63.       int to_return = 1;
      64.   
      65.       if ((e->funct_ref == 0) && e->init)
                                           ^
      66.           /*
      67.            * This is the first functional reference and the engine requires

crypto/engine/eng_init.c:70:9: Skipping __function_pointer__(): unresolved function pointer
      68.            * initialisation so we do it now.
      69.            */
      70.           to_return = e->init(e);
                    ^
      71.       if (to_return) {
      72.           /*

crypto/engine/eng_init.c:71:9: Taking false branch
      69.            */
      70.           to_return = e->init(e);
      71.       if (to_return) {
                    ^
      72.           /*
      73.            * OK, we return a functional reference which is also a structural

crypto/engine/eng_init.c:81:5: 
      79.           engine_ref_debug(e, 1, 1);
      80.       }
      81. >     return to_return;
      82.   }
      83.   

crypto/engine/eng_init.c:82:1: return from a call to engine_unlocked_init
      80.       }
      81.       return to_return;
      82. > }
      83.   
      84.   /*

crypto/engine/eng_init.c:130:5: 
    128.       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
    129.       ret = engine_unlocked_init(e);
    130. >     CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    131.       return ret;
    132.   }

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking true branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:453:9: Skipping __function_pointer__(): unresolved function pointer
      451.           }
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
                     ^
      454.   }
      455.   

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/engine/eng_init.c:131:5: 
    129.       ret = engine_unlocked_init(e);
    130.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    131. >     return ret;
    132.   }
    133.   

crypto/engine/eng_init.c:132:1: return from a call to ENGINE_init
    130.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
    131.       return ret;
    132. > }
    133.   
    134.   /* The API (locked) version of "finish" */

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

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

crypto/evp/digest.c:297:9: 
  295.       if (in->engine && !ENGINE_init(in->engine)) {
  296.           EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);
  297. >         return 0;
  298.       }
  299.   #endif

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,

ssl/ssl_lib.c:3643:10: Taking true branch
3641.           goto err;
3642.       }
3643.       if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
                 ^
3644.           || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
3645.           ret = 0;

ssl/ssl_lib.c:3645:9: 
3643.       if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
3644.           || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
3645. >         ret = 0;
3646.    err:
3647.       EVP_MD_CTX_free(ctx);

ssl/ssl_lib.c:3646:2: 
3644.           || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
3645.           ret = 0;
3646. >  err:
3647.       EVP_MD_CTX_free(ctx);
3648.       return ret;

ssl/ssl_lib.c:3647:5: 
3645.           ret = 0;
3646.    err:
3647. >     EVP_MD_CTX_free(ctx);
3648.       return ret;
3649.   }

crypto/evp/digest.c:152:1: start of procedure EVP_MD_CTX_free()
  150.   }
  151.   
  152. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  153.   {
  154.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:154:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  152.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  153.   {
  154.       EVP_MD_CTX_reset(ctx);
             ^
  155.       OPENSSL_free(ctx);
  156.   }

crypto/evp/digest.c:155:5: 
  153.   {
  154.       EVP_MD_CTX_reset(ctx);
  155. >     OPENSSL_free(ctx);
  156.   }
  157.   

crypto/mem.c:210:1: start of procedure CRYPTO_free()
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:212:9: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:212:30: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:213:9: Skipping __function_pointer__(): unresolved function pointer
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
                   ^
    214.           return;
    215.       }

crypto/mem.c:214:9: 
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
    214. >         return;
    215.       }
    216.   

crypto/mem.c:228:1: return from a call to CRYPTO_free
    226.       free(str);
    227.   #endif
    228. > }
    229.   
    230.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:156:1: return from a call to EVP_MD_CTX_free
  154.       EVP_MD_CTX_reset(ctx);
  155.       OPENSSL_free(ctx);
  156. > }
  157.   
  158.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)
{
    EVP_MD_CTX *ctx = NULL;
    EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
    int ret = EVP_MD_CTX_size(hdgst);
    if (ret < 0 || ret > outlen) {
        ret = 0;
        goto err;
    }
    ctx = EVP_MD_CTX_new();
    if (ctx == NULL) {
        ret = 0;
        goto err;
    }
    if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
        || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
        ret = 0;
 err:
    EVP_MD_CTX_free(ctx);
    return ret;
}
['int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)\n{\n    EVP_MD_CTX *ctx = NULL;\n    EVP_MD_CTX *hdgst = s->s3->handshake_dgst;\n    int ret = EVP_MD_CTX_size(hdgst);\n    if (ret < 0 || ret > outlen) {\n        ret = 0;\n        goto err;\n    }\n    ctx = EVP_MD_CTX_new();\n    if (ctx == NULL) {\n        ret = 0;\n        goto err;\n    }\n    if (!EVP_MD_CTX_copy_ex(ctx, hdgst)\n        || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)\n        ret = 0;\n err:\n    EVP_MD_CTX_free(ctx);\n    return ret;\n}', 'const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)\n{\n    if (!ctx)\n        return NULL;\n    return ctx->digest;\n}', 'int EVP_MD_size(const EVP_MD *md)\n{\n    if (!md) {\n        EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);\n        return -1;\n    }\n    return md->md_size;\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}', '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    CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);\n    ret = engine_unlocked_init(e);\n    CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);\n    return ret;\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}', 'int engine_unlocked_init(ENGINE *e)\n{\n    int to_return = 1;\n    if ((e->funct_ref == 0) && e->init)\n        to_return = e->init(e);\n    if (to_return) {\n        e->struct_ref++;\n        e->funct_ref++;\n        engine_ref_debug(e, 0, 1);\n        engine_ref_debug(e, 1, 1);\n    }\n    return to_return;\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    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}']