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


ssl/ssl_sess.c:180:1: start of procedure SSL_SESSION_new()
178.   }
179.   
180. > SSL_SESSION *SSL_SESSION_new(void)
181.   {
182.       SSL_SESSION *ss;

ssl/ssl_sess.c:184:5: 
182.       SSL_SESSION *ss;
183.   
184. >     ss = OPENSSL_zalloc(sizeof(*ss));
185.       if (ss == NULL) {
186.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);

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)

ssl/ssl_sess.c:185:9: Taking false branch
183.   
184.       ss = OPENSSL_zalloc(sizeof(*ss));
185.       if (ss == NULL) {
               ^
186.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
187.           return NULL;

ssl/ssl_sess.c:190:5: 
188.       }
189.   
190. >     ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
191.       ss->references = 1;
192.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */

ssl/ssl_sess.c:191:5: 
189.   
190.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
191. >     ss->references = 1;
192.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
193.       ss->time = (unsigned long)time(NULL);

ssl/ssl_sess.c:192:5: 
190.       ss->verify_result = 1;      /* avoid 0 (= X509_V_OK) just in case */
191.       ss->references = 1;
192. >     ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
193.       ss->time = (unsigned long)time(NULL);
194.       ss->lock = CRYPTO_THREAD_lock_new();

ssl/ssl_sess.c:193:5: 
191.       ss->references = 1;
192.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
193. >     ss->time = (unsigned long)time(NULL);
194.       ss->lock = CRYPTO_THREAD_lock_new();
195.       if (ss->lock == NULL) {

ssl/ssl_sess.c:194:5: 
192.       ss->timeout = 60 * 5 + 4;   /* 5 minute timeout by default */
193.       ss->time = (unsigned long)time(NULL);
194. >     ss->lock = CRYPTO_THREAD_lock_new();
195.       if (ss->lock == NULL) {
196.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);

crypto/threads_pthread.c:55:1: start of procedure CRYPTO_THREAD_lock_new()
  53.   #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
  54.   
  55. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  56.   {
  57.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));

crypto/threads_pthread.c:57:5: 
  55.   CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  56.   {
  57. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  58.       if (lock == NULL)
  59.           return NULL;

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/threads_pthread.c:58:9: Taking false branch
  56.   {
  57.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  58.       if (lock == NULL)
                ^
  59.           return NULL;
  60.   

crypto/threads_pthread.c:61:9: Taking false branch
  59.           return NULL;
  60.   
  61.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  62.           OPENSSL_free(lock);
  63.           return NULL;

crypto/threads_pthread.c:66:5: 
  64.       }
  65.   
  66. >     return lock;
  67.   }
  68.   

crypto/threads_pthread.c:67:1: return from a call to CRYPTO_THREAD_lock_new
  65.   
  66.       return lock;
  67. > }
  68.   
  69.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

ssl/ssl_sess.c:195:9: Taking false branch
193.       ss->time = (unsigned long)time(NULL);
194.       ss->lock = CRYPTO_THREAD_lock_new();
195.       if (ss->lock == NULL) {
               ^
196.           SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
197.           OPENSSL_free(ss);

ssl/ssl_sess.c:201:10: 
199.       }
200.   
201. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
202.           CRYPTO_THREAD_lock_free(ss->lock);
203.           OPENSSL_free(ss);

crypto/ex_data.c:304:1: start of procedure CRYPTO_new_ex_data()
  302.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  303.    */
  304. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  305.   {
  306.       int mx, i;

crypto/ex_data.c:308:5: 
  306.       int mx, i;
  307.       void *ptr;
  308. >     EX_CALLBACK **storage = NULL;
  309.       EX_CALLBACK *stack[10];
  310.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:310:5: 
  308.       EX_CALLBACK **storage = NULL;
  309.       EX_CALLBACK *stack[10];
  310. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  311.   
  312.       if (ip == NULL)

crypto/ex_data.c:149:1: start of procedure get_and_lock()
    147.    * a given class.  On success, *holds the lock.*
    148.    */
    149. > static EX_CALLBACKS *get_and_lock(int class_index)
    150.   {
    151.       EX_CALLBACKS *ip;

crypto/ex_data.c:153:9: Taking false branch
    151.       EX_CALLBACKS *ip;
    152.   
    153.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                   ^
    154.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    155.           return NULL;

crypto/ex_data.c:153:28: Taking false branch
    151.       EX_CALLBACKS *ip;
    152.   
    153.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                                      ^
    154.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    155.           return NULL;

crypto/ex_data.c:158:5: 
    156.       }
    157.   
    158. >     CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    159.   
    160.       if (ex_data_lock == NULL) {

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

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

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

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

crypto/ex_data.c:160:9: Taking true branch
    158.       CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    159.   
    160.       if (ex_data_lock == NULL) {
                   ^
    161.           /*
    162.            * This can happen in normal operation when using CRYPTO_mem_leaks().

crypto/ex_data.c:170:10: 
    168.            * ignore this operation. We just treat it as an error.
    169.            */
    170. >          return NULL;
    171.       }
    172.   

crypto/ex_data.c:176:1: return from a call to get_and_lock
    174.       CRYPTO_THREAD_write_lock(ex_data_lock);
    175.       return ip;
    176. > }
    177.   
    178.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:312:9: Taking true branch
  310.       EX_CALLBACKS *ip = get_and_lock(class_index);
  311.   
  312.       if (ip == NULL)
                 ^
  313.           return 0;
  314.   

crypto/ex_data.c:313:9: 
  311.   
  312.       if (ip == NULL)
  313. >         return 0;
  314.   
  315.       ad->sk = NULL;

crypto/ex_data.c:343:1: return from a call to CRYPTO_new_ex_data
  341.           OPENSSL_free(storage);
  342.       return 1;
  343. > }
  344.   
  345.   /*

ssl/ssl_sess.c:201:10: Taking true branch
199.       }
200.   
201.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
                ^
202.           CRYPTO_THREAD_lock_free(ss->lock);
203.           OPENSSL_free(ss);

ssl/ssl_sess.c:202:9: 
200.   
201.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
202. >         CRYPTO_THREAD_lock_free(ss->lock);
203.           OPENSSL_free(ss);
204.           return NULL;

crypto/threads_pthread.c:93:1: start of procedure CRYPTO_THREAD_lock_free()
  91.   }
  92.   
  93. > void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  94.   {
  95.       if (lock == NULL)

crypto/threads_pthread.c:95:9: Taking false branch
  93.   void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  94.   {
  95.       if (lock == NULL)
                ^
  96.           return;
  97.   

crypto/threads_pthread.c:98:5: Skipping pthread_rwlock_destroy(): method has no implementation
  96.           return;
  97.   
  98.       pthread_rwlock_destroy(lock);
             ^
  99.       OPENSSL_free(lock);
  100.   

crypto/threads_pthread.c:99:5: 
  97.   
  98.       pthread_rwlock_destroy(lock);
  99. >     OPENSSL_free(lock);
  100.   
  101.       return;

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

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

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

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

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

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

crypto/threads_pthread.c:101:5: 
  99.       OPENSSL_free(lock);
  100.   
  101. >     return;
  102.   }
  103.   

crypto/threads_pthread.c:102:1: return from a call to CRYPTO_THREAD_lock_free
  100.   
  101.       return;
  102. > }
  103.   
  104.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))

ssl/ssl_sess.c:203:9: 
201.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) {
202.           CRYPTO_THREAD_lock_free(ss->lock);
203. >         OPENSSL_free(ss);
204.           return NULL;
205.       }

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

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

crypto/mem.c:227:5: 
  225.       }
  226.   #else
  227. >     free(str);
  228.   #endif
  229.   }

crypto/mem.c:229:1: return from a call to CRYPTO_free
  227.       free(str);
  228.   #endif
  229. > }
  230.   
  231.   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    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}', '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}']