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


ssl/ssl_sess.c:80:1: start of procedure SSL_SESSION_new()
78.   }
79.   
80. > SSL_SESSION *SSL_SESSION_new(void)
81.   {
82.       SSL_SESSION *ss;

ssl/ssl_sess.c:84:5: 
82.       SSL_SESSION *ss;
83.   
84. >     ss = OPENSSL_zalloc(sizeof(*ss));
85.       if (ss == NULL) {
86.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);

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)

ssl/ssl_sess.c:85:9: Taking false branch
83.   
84.       ss = OPENSSL_zalloc(sizeof(*ss));
85.       if (ss == NULL) {
              ^
86.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
87.           return NULL;

ssl/ssl_sess.c:90:5: 
88.       }
89.   
90. >     ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
91.       ss->references = 1;
92.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */

ssl/ssl_sess.c:91:5: 
89.   
90.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
91. >     ss->references = 1;
92.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
93.       ss->time = (unsigned long)time(NULL);

ssl/ssl_sess.c:92:5: 
90.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
91.       ss->references = 1;
92. >     ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
93.       ss->time = (unsigned long)time(NULL);
94.       ss->lock = CRYPTO_THREAD_lock_new();

ssl/ssl_sess.c:93:5: 
91.       ss->references = 1;
92.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
93. >     ss->time = (unsigned long)time(NULL);
94.       ss->lock = CRYPTO_THREAD_lock_new();
95.       if (ss->lock == NULL) {

ssl/ssl_sess.c:94:5: 
92.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
93.       ss->time = (unsigned long)time(NULL);
94. >     ss->lock = CRYPTO_THREAD_lock_new();
95.       if (ss->lock == NULL) {
96.           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: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)

ssl/ssl_sess.c:95:9: Taking false branch
93.       ss->time = (unsigned long)time(NULL);
94.       ss->lock = CRYPTO_THREAD_lock_new();
95.       if (ss->lock == NULL) {
              ^
96.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
97.           OPENSSL_free(ss);

ssl/ssl_sess.c:101:10: 
99.       }
100.   
101. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
102.           CRYPTO_THREAD_lock_free(ss->lock);
103.           OPENSSL_free(ss);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ssl/ssl_sess.c:101:10: Taking true branch
99.       }
100.   
101.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
                ^
102.           CRYPTO_THREAD_lock_free(ss->lock);
103.           OPENSSL_free(ss);

ssl/ssl_sess.c:102:9: 
100.   
101.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
102. >         CRYPTO_THREAD_lock_free(ss->lock);
103.           OPENSSL_free(ss);
104.           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:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   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:103:9: 
101.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
102.           CRYPTO_THREAD_lock_free(ss->lock);
103. >         OPENSSL_free(ss);
104.           return NULL;
105.       }

crypto/mem.c:163:1: start of procedure CRYPTO_free()
  161.   }
  162.   
  163. > void CRYPTO_free(void *str, const char *file, int line)
  164.   {
  165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking false branch
  163.   void CRYPTO_free(void *str, const char *file, int line)
  164.   {
  165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                 ^
  166.           free_impl(str, file, line);
  167.           return;

crypto/mem.c:179:5: 
  177.       }
  178.   #else
  179. >     free(str);
  180.   #endif
  181.   }

crypto/mem.c:181:1: return from a call to CRYPTO_free
  179.       free(str);
  180.   #endif
  181. > }
  182.   
  183.   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    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}', '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}']