crypto/dh/dh_lib.c:100: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_zalloc()` at line 57, column 15 is not reachable after line 100, column 9.
Showing all 86 steps of the trace


crypto/dh/dh_lib.c:55:1: start of procedure DH_new_method()
53.   }
54.   
55. > DH *DH_new_method(ENGINE *engine)
56.   {
57.       DH *ret = OPENSSL_zalloc(sizeof(*ret));

crypto/dh/dh_lib.c:57:5: 
55.   DH *DH_new_method(ENGINE *engine)
56.   {
57. >     DH *ret = OPENSSL_zalloc(sizeof(*ret));
58.   
59.       if (ret == NULL) {

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/dh/dh_lib.c:59:9: Taking false branch
57.       DH *ret = OPENSSL_zalloc(sizeof(*ret));
58.   
59.       if (ret == NULL) {
              ^
60.           DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
61.           return NULL;

crypto/dh/dh_lib.c:64:5: 
62.       }
63.   
64. >     ret->references = 1;
65.       ret->lock = CRYPTO_THREAD_lock_new();
66.       if (ret->lock == NULL) {

crypto/dh/dh_lib.c:65:5: 
63.   
64.       ret->references = 1;
65. >     ret->lock = CRYPTO_THREAD_lock_new();
66.       if (ret->lock == NULL) {
67.           DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);

crypto/threads_pthread.c:14:1: start of procedure CRYPTO_THREAD_lock_new()
  12.   #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
  13.   
  14. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  15.   {
  16.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));

crypto/threads_pthread.c:16:5: 
  14.   CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  15.   {
  16. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  17.       if (lock == NULL)
  18.           return NULL;

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/threads_pthread.c:17:9: Taking false branch
  15.   {
  16.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  17.       if (lock == NULL)
                ^
  18.           return NULL;
  19.   

crypto/threads_pthread.c:20:9: Taking false branch
  18.           return NULL;
  19.   
  20.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  21.           OPENSSL_free(lock);
  22.           return NULL;

crypto/threads_pthread.c:25:5: 
  23.       }
  24.   
  25. >     return lock;
  26.   }
  27.   

crypto/threads_pthread.c:26:1: return from a call to CRYPTO_THREAD_lock_new
  24.   
  25.       return lock;
  26. > }
  27.   
  28.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

crypto/dh/dh_lib.c:66:9: Taking false branch
64.       ret->references = 1;
65.       ret->lock = CRYPTO_THREAD_lock_new();
66.       if (ret->lock == NULL) {
              ^
67.           DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
68.           OPENSSL_free(ret);

crypto/dh/dh_lib.c:72:5: 
70.       }
71.   
72. >     ret->meth = DH_get_default_method();
73.   #ifndef OPENSSL_NO_ENGINE
74.       ret->flags = ret->meth->flags;  /* early default init */

crypto/dh/dh_lib.c:23:1: start of procedure DH_get_default_method()
  21.   }
  22.   
  23. > const DH_METHOD *DH_get_default_method(void)
  24.   {
  25.       if (!default_DH_method)

crypto/dh/dh_lib.c:25:10: Taking false branch
  23.   const DH_METHOD *DH_get_default_method(void)
  24.   {
  25.       if (!default_DH_method)
                 ^
  26.           default_DH_method = DH_OpenSSL();
  27.       return default_DH_method;

crypto/dh/dh_lib.c:27:5: 
  25.       if (!default_DH_method)
  26.           default_DH_method = DH_OpenSSL();
  27. >     return default_DH_method;
  28.   }
  29.   

crypto/dh/dh_lib.c:28:1: return from a call to DH_get_default_method
  26.           default_DH_method = DH_OpenSSL();
  27.       return default_DH_method;
  28. > }
  29.   
  30.   int DH_set_method(DH *dh, const DH_METHOD *meth)

crypto/dh/dh_lib.c:74:5: 
72.       ret->meth = DH_get_default_method();
73.   #ifndef OPENSSL_NO_ENGINE
74. >     ret->flags = ret->meth->flags;  /* early default init */
75.       if (engine) {
76.           if (!ENGINE_init(engine)) {

crypto/dh/dh_lib.c:75:9: Taking false branch
73.   #ifndef OPENSSL_NO_ENGINE
74.       ret->flags = ret->meth->flags;  /* early default init */
75.       if (engine) {
              ^
76.           if (!ENGINE_init(engine)) {
77.               DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);

crypto/dh/dh_lib.c:82:9: 
80.           ret->engine = engine;
81.       } else
82. >         ret->engine = ENGINE_get_default_DH();
83.       if (ret->engine) {
84.           ret->meth = ENGINE_get_DH(ret->engine);

crypto/engine/tb_dh.c:56:1: start of procedure ENGINE_get_default_DH()
  54.    * references).
  55.    */
  56. > ENGINE *ENGINE_get_default_DH(void)
  57.   {
  58.       return engine_table_select(&dh_table, dummy_nid);

crypto/engine/tb_dh.c:58:5: 
  56.   ENGINE *ENGINE_get_default_DH(void)
  57.   {
  58. >     return engine_table_select(&dh_table, dummy_nid);
  59.   }
  60.   

crypto/engine/eng_table.c:188:1: start of procedure engine_table_select()
    186.   /* return a functional reference for a given 'nid' */
    187.   #ifndef ENGINE_TABLE_DEBUG
    188. > ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
    189.   #else
    190.   ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,

crypto/engine/eng_table.c:194:5: 
    192.   #endif
    193.   {
    194. >     ENGINE *ret = NULL;
    195.       ENGINE_PILE tmplate, *fnd = NULL;
    196.       int initres, loop = 0;

crypto/engine/eng_table.c:195:5: 
    193.   {
    194.       ENGINE *ret = NULL;
    195. >     ENGINE_PILE tmplate, *fnd = NULL;
    196.       int initres, loop = 0;
    197.   

crypto/engine/eng_table.c:196:5: 
    194.       ENGINE *ret = NULL;
    195.       ENGINE_PILE tmplate, *fnd = NULL;
    196. >     int initres, loop = 0;
    197.   
    198.       if (!(*table)) {

crypto/engine/eng_table.c:198:11: 
    196.       int initres, loop = 0;
    197.   
    198. >     if (!(*table)) {
    199.   #ifdef ENGINE_TABLE_DEBUG
    200.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:198:10: Taking true branch
    196.       int initres, loop = 0;
    197.   
    198.       if (!(*table)) {
                    ^
    199.   #ifdef ENGINE_TABLE_DEBUG
    200.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:203:9: 
    201.                   "registered!\n", f, l, nid);
    202.   #endif
    203. >         return NULL;
    204.       }
    205.       ERR_set_mark();

crypto/engine/eng_table.c:284:1: return from a call to engine_table_select
    282.       ERR_pop_to_mark();
    283.       return ret;
    284. > }
    285.   
    286.   /* Table enumeration */

crypto/engine/tb_dh.c:59:1: return from a call to ENGINE_get_default_DH
  57.   {
  58.       return engine_table_select(&dh_table, dummy_nid);
  59. > }
  60.   
  61.   /* Obtains an DH implementation from an ENGINE functional reference */

crypto/dh/dh_lib.c:83:9: Taking false branch
81.       } else
82.           ret->engine = ENGINE_get_default_DH();
83.       if (ret->engine) {
              ^
84.           ret->meth = ENGINE_get_DH(ret->engine);
85.           if (ret->meth == NULL) {

crypto/dh/dh_lib.c:92:5: 
90.   #endif
91.   
92. >     ret->flags = ret->meth->flags;
93.   
94.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data))

crypto/dh/dh_lib.c:94:10: 
92.       ret->flags = ret->meth->flags;
93.   
94. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data))
95.           goto err;
96.   

crypto/ex_data.c:202:1: start of procedure CRYPTO_new_ex_data()
  200.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  201.    */
  202. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  203.   {
  204.       int mx, i;

crypto/ex_data.c:206:5: 
  204.       int mx, i;
  205.       void *ptr;
  206. >     EX_CALLBACK **storage = NULL;
  207.       EX_CALLBACK *stack[10];
  208.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:208:5: 
  206.       EX_CALLBACK **storage = NULL;
  207.       EX_CALLBACK *stack[10];
  208. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  209.   
  210.       if (ip == NULL)

crypto/ex_data.c:47:1: start of procedure get_and_lock()
    45.    * a given class.  On success, *holds the lock.*
    46.    */
    47. > static EX_CALLBACKS *get_and_lock(int class_index)
    48.   {
    49.       EX_CALLBACKS *ip;

crypto/ex_data.c:51:9: Taking false branch
    49.       EX_CALLBACKS *ip;
    50.   
    51.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                  ^
    52.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    53.           return NULL;

crypto/ex_data.c:51:28: Taking false branch
    49.       EX_CALLBACKS *ip;
    50.   
    51.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                                     ^
    52.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    53.           return NULL;

crypto/ex_data.c:56:5: 
    54.       }
    55.   
    56. >     CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    57.   
    58.       if (ex_data_lock == NULL) {

crypto/threads_pthread.c:63:1: start of procedure CRYPTO_THREAD_run_once()
      61.   }
      62.   
      63. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      64.   {
      65.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:65:9: Taking true branch
      63.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      64.   {
      65.       if (pthread_once(once, init) != 0)
                    ^
      66.           return 0;
      67.   

crypto/threads_pthread.c:66:9: 
      64.   {
      65.       if (pthread_once(once, init) != 0)
      66. >         return 0;
      67.   
      68.       return 1;

crypto/threads_pthread.c:69:1: return from a call to CRYPTO_THREAD_run_once
      67.   
      68.       return 1;
      69. > }
      70.   
      71.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/ex_data.c:58:9: Taking true branch
    56.       CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    57.   
    58.       if (ex_data_lock == NULL) {
                  ^
    59.           /*
    60.            * This can happen in normal operation when using CRYPTO_mem_leaks().

crypto/ex_data.c:68:10: 
    66.            * ignore this operation. We just treat it as an error.
    67.            */
    68. >          return NULL;
    69.       }
    70.   

crypto/ex_data.c:74:1: return from a call to get_and_lock
    72.       CRYPTO_THREAD_write_lock(ex_data_lock);
    73.       return ip;
    74. > }
    75.   
    76.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:210:9: Taking true branch
  208.       EX_CALLBACKS *ip = get_and_lock(class_index);
  209.   
  210.       if (ip == NULL)
                 ^
  211.           return 0;
  212.   

crypto/ex_data.c:211:9: 
  209.   
  210.       if (ip == NULL)
  211. >         return 0;
  212.   
  213.       ad->sk = NULL;

crypto/ex_data.c:241:1: return from a call to CRYPTO_new_ex_data
  239.           OPENSSL_free(storage);
  240.       return 1;
  241. > }
  242.   
  243.   /*

crypto/dh/dh_lib.c:94:10: Taking true branch
92.       ret->flags = ret->meth->flags;
93.   
94.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data))
               ^
95.           goto err;
96.   

crypto/dh/dh_lib.c:99:1: 
97.       if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
98.           DHerr(DH_F_DH_NEW_METHOD, ERR_R_INIT_FAIL);
99. > err:
100.           DH_free(ret);
101.           ret = NULL;

crypto/dh/dh_lib.c:100:9: Skipping DH_free(): empty list of specs
98.           DHerr(DH_F_DH_NEW_METHOD, ERR_R_INIT_FAIL);
99.   err:
100.           DH_free(ret);
               ^
101.           ret = NULL;
102.       }

DH *DH_new_method(ENGINE *engine)
{
    DH *ret = OPENSSL_zalloc(sizeof(*ret));
    if (ret == NULL) {
        DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    ret->references = 1;
    ret->lock = CRYPTO_THREAD_lock_new();
    if (ret->lock == NULL) {
        DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(ret);
        return NULL;
    }
    ret->meth = DH_get_default_method();
#ifndef OPENSSL_NO_ENGINE
    ret->flags = ret->meth->flags;
    if (engine) {
        if (!ENGINE_init(engine)) {
            DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);
            goto err;
        }
        ret->engine = engine;
    } else
        ret->engine = ENGINE_get_default_DH();
    if (ret->engine) {
        ret->meth = ENGINE_get_DH(ret->engine);
        if (ret->meth == NULL) {
            DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);
            goto err;
        }
    }
#endif
    ret->flags = ret->meth->flags;
    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data))
        goto err;
    if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
        DHerr(DH_F_DH_NEW_METHOD, ERR_R_INIT_FAIL);
err:
        DH_free(ret);
        ret = NULL;
    }
    return ret;
}
['DH *DH_new_method(ENGINE *engine)\n{\n    DH *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->references = 1;\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    ret->meth = DH_get_default_method();\n#ifndef OPENSSL_NO_ENGINE\n    ret->flags = ret->meth->flags;\n    if (engine) {\n        if (!ENGINE_init(engine)) {\n            DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n        ret->engine = engine;\n    } else\n        ret->engine = ENGINE_get_default_DH();\n    if (ret->engine) {\n        ret->meth = ENGINE_get_DH(ret->engine);\n        if (ret->meth == NULL) {\n            DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);\n            goto err;\n        }\n    }\n#endif\n    ret->flags = ret->meth->flags;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data))\n        goto err;\n    if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {\n        DHerr(DH_F_DH_NEW_METHOD, ERR_R_INIT_FAIL);\nerr:\n        DH_free(ret);\n        ret = NULL;\n    }\n    return ret;\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}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n    CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));\n    if (lock == NULL)\n        return NULL;\n    if (pthread_rwlock_init(lock, NULL) != 0) {\n        OPENSSL_free(lock);\n        return NULL;\n    }\n    return lock;\n}', 'const DH_METHOD *DH_get_default_method(void)\n{\n    if (!default_DH_method)\n        default_DH_method = DH_OpenSSL();\n    return default_DH_method;\n}', 'ENGINE *ENGINE_get_default_DH(void)\n{\n    return engine_table_select(&dh_table, dummy_nid);\n}', 'ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)\n#else\nENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,\n                                int l)\n#endif\n{\n    ENGINE *ret = NULL;\n    ENGINE_PILE tmplate, *fnd = NULL;\n    int initres, loop = 0;\n    if (!(*table)) {\n#ifdef ENGINE_TABLE_DEBUG\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "\n                "registered!\\n", f, l, nid);\n#endif\n        return NULL;\n    }\n    ERR_set_mark();\n    CRYPTO_THREAD_write_lock(global_engine_lock);\n    if (!int_table_check(table, 0))\n        goto end;\n    tmplate.nid = nid;\n    fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);\n    if (!fnd)\n        goto end;\n    if (fnd->funct && engine_unlocked_init(fnd->funct)) {\n#ifdef ENGINE_TABLE_DEBUG\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "\n                "ENGINE \'%s\' cached\\n", f, l, nid, fnd->funct->id);\n#endif\n        ret = fnd->funct;\n        goto end;\n    }\n    if (fnd->uptodate) {\n        ret = fnd->funct;\n        goto end;\n    }\n trynext:\n    ret = sk_ENGINE_value(fnd->sk, loop++);\n    if (!ret) {\n#ifdef ENGINE_TABLE_DEBUG\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "\n                "registered implementations would initialise\\n", f, l, nid);\n#endif\n        goto end;\n    }\n    if ((ret->funct_ref > 0) || !(table_flags & ENGINE_TABLE_FLAG_NOINIT))\n        initres = engine_unlocked_init(ret);\n    else\n        initres = 0;\n    if (initres) {\n        if ((fnd->funct != ret) && engine_unlocked_init(ret)) {\n            if (fnd->funct)\n                engine_unlocked_finish(fnd->funct, 0);\n            fnd->funct = ret;\n#ifdef ENGINE_TABLE_DEBUG\n            fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, "\n                    "setting default to \'%s\'\\n", f, l, nid, ret->id);\n#endif\n        }\n#ifdef ENGINE_TABLE_DEBUG\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "\n                "newly initialised \'%s\'\\n", f, l, nid, ret->id);\n#endif\n        goto end;\n    }\n    goto trynext;\n end:\n    if (fnd)\n        fnd->uptodate = 1;\n#ifdef ENGINE_TABLE_DEBUG\n    if (ret)\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "\n                "ENGINE \'%s\'\\n", f, l, nid, ret->id);\n    else\n        fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "\n                "\'no matching ENGINE\'\\n", f, l, nid);\n#endif\n    CRYPTO_THREAD_unlock(global_engine_lock);\n    ERR_pop_to_mark();\n    return ret;\n}', 'int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)\n{\n    int mx, i;\n    void *ptr;\n    EX_CALLBACK **storage = NULL;\n    EX_CALLBACK *stack[10];\n    EX_CALLBACKS *ip = get_and_lock(class_index);\n    if (ip == NULL)\n        return 0;\n    ad->sk = NULL;\n    mx = sk_EX_CALLBACK_num(ip->meth);\n    if (mx > 0) {\n        if (mx < (int)OSSL_NELEM(stack))\n            storage = stack;\n        else\n            storage = OPENSSL_malloc(sizeof(*storage) * mx);\n        if (storage != NULL)\n            for (i = 0; i < mx; i++)\n                storage[i] = sk_EX_CALLBACK_value(ip->meth, i);\n    }\n    CRYPTO_THREAD_unlock(ex_data_lock);\n    if (mx > 0 && storage == NULL) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    for (i = 0; i < mx; i++) {\n        if (storage[i] && storage[i]->new_func) {\n            ptr = CRYPTO_get_ex_data(ad, i);\n            storage[i]->new_func(obj, ptr, ad, i,\n                                 storage[i]->argl, storage[i]->argp);\n        }\n    }\n    if (storage != stack)\n        OPENSSL_free(storage);\n    return 1;\n}', 'static EX_CALLBACKS *get_and_lock(int class_index)\n{\n    EX_CALLBACKS *ip;\n    if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {\n        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);\n        return NULL;\n    }\n    CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);\n    if (ex_data_lock == NULL) {\n         return NULL;\n    }\n    ip = &ex_data[class_index];\n    CRYPTO_THREAD_write_lock(ex_data_lock);\n    return ip;\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}']