ssl/ssl_sess.c:113: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 104, column 16 is not reachable after line 113, column 9.
Showing all 86 steps of the trace


ssl/ssl_sess.c:90:1: start of procedure SSL_SESSION_new()
88.   }
89.   
90. > SSL_SESSION *SSL_SESSION_new(void)
91.   {
92.       SSL_SESSION *ss;

ssl/ssl_sess.c:94:5: 
92.       SSL_SESSION *ss;
93.   
94. >     ss = OPENSSL_zalloc(sizeof(*ss));
95.       if (ss == NULL) {
96.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
  184.   }
  185.   
  186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188. >     void *ret = CRYPTO_malloc(num, file, line);
  189.   
  190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
    156.   #endif
    157.   
    158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160.       void *ret = NULL;

crypto/mem.c:160:5: 
    158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160. >     void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:165:9: Taking false branch
    163.           return malloc_impl(num, file, line);
    164.   
    165.       if (num <= 0)
                   ^
    166.           return NULL;
    167.   

crypto/mem.c:169:5: 
    167.   
    168.       FAILTEST();
    169. >     allow_customize = 0;
    170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:179:24: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:180:5: 
    178.   #else
    179.       osslargused(file); osslargused(line);
    180. >     ret = malloc(num);
    181.   #endif
    182.   

crypto/mem.c:183:5: 
    181.   #endif
    182.   
    183. >     return ret;
    184.   }
    185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
    182.   
    183.       return ret;
    184. > }
    185.   
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
  189.   
  190.       FAILTEST();
  191.       if (ret != NULL)
                 ^
  192.           memset(ret, 0, num);
  193.       return ret;

crypto/mem.c:192:9: 
  190.       FAILTEST();
  191.       if (ret != NULL)
  192. >         memset(ret, 0, num);
  193.       return ret;
  194.   }

crypto/mem.c:193:5: 
  191.       if (ret != NULL)
  192.           memset(ret, 0, num);
  193. >     return ret;
  194.   }
  195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
  192.           memset(ret, 0, num);
  193.       return ret;
  194. > }
  195.   
  196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

ssl/ssl_sess.c:95:9: Taking false branch
93.   
94.       ss = OPENSSL_zalloc(sizeof(*ss));
95.       if (ss == NULL) {
              ^
96.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
97.           return NULL;

ssl/ssl_sess.c:100:5: 
98.       }
99.   
100. >     ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
101.       ss->references = 1;
102.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */

ssl/ssl_sess.c:101:5: 
99.   
100.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
101. >     ss->references = 1;
102.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
103.       ss->time = (unsigned long)time(NULL);

ssl/ssl_sess.c:102:5: 
100.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
101.       ss->references = 1;
102. >     ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
103.       ss->time = (unsigned long)time(NULL);
104.       ss->lock = CRYPTO_THREAD_lock_new();

ssl/ssl_sess.c:103:5: 
101.       ss->references = 1;
102.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
103. >     ss->time = (unsigned long)time(NULL);
104.       ss->lock = CRYPTO_THREAD_lock_new();
105.       if (ss->lock == NULL) {

ssl/ssl_sess.c:104:5: 
102.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
103.       ss->time = (unsigned long)time(NULL);
104. >     ss->lock = CRYPTO_THREAD_lock_new();
105.       if (ss->lock == NULL) {
106.           SSLerr(SSL_F_SSL_SESSION_NEW, 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:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
      156.   #endif
      157.   
      158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160.       void *ret = NULL;

crypto/mem.c:160:5: 
      158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160. >     void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
      160.       void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      163.           return malloc_impl(num, file, line);
      164.   

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num <= 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   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)

ssl/ssl_sess.c:105:9: Taking false branch
103.       ss->time = (unsigned long)time(NULL);
104.       ss->lock = CRYPTO_THREAD_lock_new();
105.       if (ss->lock == NULL) {
               ^
106.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
107.           OPENSSL_free(ss);

ssl/ssl_sess.c:111:10: 
109.       }
110.   
111. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
112.           CRYPTO_THREAD_lock_free(ss->lock);
113.           OPENSSL_free(ss);

crypto/ex_data.c:208:1: start of procedure CRYPTO_new_ex_data()
  206.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  207.    */
  208. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  209.   {
  210.       int mx, i;

crypto/ex_data.c:212:5: 
  210.       int mx, i;
  211.       void *ptr;
  212. >     EX_CALLBACK **storage = NULL;
  213.       EX_CALLBACK *stack[10];
  214.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:214:5: 
  212.       EX_CALLBACK **storage = NULL;
  213.       EX_CALLBACK *stack[10];
  214. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  215.   
  216.       if (ip == NULL)

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

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

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

crypto/ex_data.c:59:10: 
    57.       }
    58.   
    59. >     if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return 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:59:10: Condition is false
    57.       }
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
                   ^
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return NULL;

crypto/ex_data.c:59:10: Taking true branch
    57.       }
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
                   ^
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return NULL;

crypto/ex_data.c:60:9: Skipping ERR_put_error(): empty list of specs
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
                  ^
    61.           return NULL;
    62.       }

crypto/ex_data.c:61:9: 
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61. >         return NULL;
    62.       }
    63.   

crypto/ex_data.c:80:1: return from a call to get_and_lock
    78.       CRYPTO_THREAD_write_lock(ex_data_lock);
    79.       return ip;
    80. > }
    81.   
    82.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:216:9: Taking true branch
  214.       EX_CALLBACKS *ip = get_and_lock(class_index);
  215.   
  216.       if (ip == NULL)
                 ^
  217.           return 0;
  218.   

crypto/ex_data.c:217:9: 
  215.   
  216.       if (ip == NULL)
  217. >         return 0;
  218.   
  219.       ad->sk = NULL;

crypto/ex_data.c:247:1: return from a call to CRYPTO_new_ex_data
  245.           OPENSSL_free(storage);
  246.       return 1;
  247. > }
  248.   
  249.   /*

ssl/ssl_sess.c:111:10: Taking true branch
109.       }
110.   
111.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
                ^
112.           CRYPTO_THREAD_lock_free(ss->lock);
113.           OPENSSL_free(ss);

ssl/ssl_sess.c:112:9: 
110.   
111.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
112. >         CRYPTO_THREAD_lock_free(ss->lock);
113.           OPENSSL_free(ss);
114.           return NULL;

crypto/threads_pthread.c:52:1: start of procedure CRYPTO_THREAD_lock_free()
  50.   }
  51.   
  52. > void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  53.   {
  54.       if (lock == NULL)

crypto/threads_pthread.c:54:9: Taking false branch
  52.   void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  53.   {
  54.       if (lock == NULL)
                ^
  55.           return;
  56.   

crypto/threads_pthread.c:57:5: Skipping pthread_rwlock_destroy(): method has no implementation
  55.           return;
  56.   
  57.       pthread_rwlock_destroy(lock);
            ^
  58.       OPENSSL_free(lock);
  59.   

crypto/threads_pthread.c:58:5: 
  56.   
  57.       pthread_rwlock_destroy(lock);
  58. >     OPENSSL_free(lock);
  59.   
  60.       return;

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:60:5: 
  58.       OPENSSL_free(lock);
  59.   
  60. >     return;
  61.   }
  62.   

crypto/threads_pthread.c:61:1: return from a call to CRYPTO_THREAD_lock_free
  59.   
  60.       return;
  61. > }
  62.   
  63.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))

ssl/ssl_sess.c:113:9: 
111.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
112.           CRYPTO_THREAD_lock_free(ss->lock);
113. >         OPENSSL_free(ss);
114.           return NULL;
115.       }

crypto/mem.c:253:1: start of procedure CRYPTO_free()
  251.   }
  252.   
  253. > void CRYPTO_free(void *str, const char *file, int line)
  254.   {
  255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking false branch
  253.   void CRYPTO_free(void *str, const char *file, int line)
  254.   {
  255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                 ^
  256.           free_impl(str, file, line);
  257.           return;

crypto/mem.c:269:5: 
  267.       }
  268.   #else
  269. >     free(str);
  270.   #endif
  271.   }

crypto/mem.c:271:1: return from a call to CRYPTO_free
  269.       free(str);
  270.   #endif
  271. > }
  272.   
  273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

SSL_SESSION *SSL_SESSION_new(void)
{
    SSL_SESSION *ss;
    ss = OPENSSL_zalloc(sizeof(*ss));
    if (ss == NULL) {
        SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    ss->verify_result = 1;
    ss->references = 1;
    ss->timeout = 60 * 5 + 4;
    ss->time = (unsigned long)time(NULL);
    ss->lock = CRYPTO_THREAD_lock_new();
    if (ss->lock == NULL) {
        SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(ss);
        return NULL;
    }
    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
        CRYPTO_THREAD_lock_free(ss->lock);
        OPENSSL_free(ss);
        return NULL;
    }
    return ss;
}
['SSL_SESSION *SSL_SESSION_new(void)\n{\n    SSL_SESSION *ss;\n    ss = OPENSSL_zalloc(sizeof(*ss));\n    if (ss == NULL) {\n        SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ss->verify_result = 1;\n    ss->references = 1;\n    ss->timeout = 60 * 5 + 4;\n    ss->time = (unsigned long)time(NULL);\n    ss->lock = CRYPTO_THREAD_lock_new();\n    if (ss->lock == NULL) {\n        SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ss);\n        return NULL;\n    }\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {\n        CRYPTO_THREAD_lock_free(ss->lock);\n        OPENSSL_free(ss);\n        return NULL;\n    }\n    return ss;\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    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    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}', '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    if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {\n        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\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}', 'void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)\n{\n    if (lock == NULL)\n        return;\n    pthread_rwlock_destroy(lock);\n    OPENSSL_free(lock);\n    return;\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}']