ssl/ssl_lib.c:645: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 627, column 15 is not reachable after line 645, column 5.
Showing all 62 steps of the trace


ssl/ssl_lib.c:610:1: start of procedure SSL_new()
608.   }
609.   
610. > SSL *SSL_new(SSL_CTX *ctx)
611.   {
612.       SSL *s;

ssl/ssl_lib.c:614:9: Taking false branch
612.       SSL *s;
613.   
614.       if (ctx == NULL) {
               ^
615.           SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX);
616.           return (NULL);

ssl/ssl_lib.c:618:9: Taking false branch
616.           return (NULL);
617.       }
618.       if (ctx->method == NULL) {
               ^
619.           SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION);
620.           return (NULL);

ssl/ssl_lib.c:623:5: 
621.       }
622.   
623. >     s = OPENSSL_zalloc(sizeof(*s));
624.       if (s == NULL)
625.           goto err;

crypto/mem.c:198:1: start of procedure CRYPTO_zalloc()
  196.   }
  197.   
  198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  199.   {
  200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
  198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  199.   {
  200. >     void *ret = CRYPTO_malloc(num, file, line);
  201.   
  202.       FAILTEST();

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
    168.   #endif
    169.   
    170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172.       void *ret = NULL;

crypto/mem.c:172:5: 
    170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172. >     void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
    172.       void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    175.           return malloc_impl(num, file, line);
    176.   

crypto/mem.c:177:9: Taking false branch
    175.           return malloc_impl(num, file, line);
    176.   
    177.       if (num == 0)
                   ^
    178.           return NULL;
    179.   

crypto/mem.c:181:5: 
    179.   
    180.       FAILTEST();
    181. >     allow_customize = 0;
    182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
    189.       }
    190.   #else
    191. >     (void)(file); (void)(line);
    192.       ret = malloc(num);
    193.   #endif

crypto/mem.c:191:19: 
    189.       }
    190.   #else
    191. >     (void)(file); (void)(line);
    192.       ret = malloc(num);
    193.   #endif

crypto/mem.c:192:5: 
    190.   #else
    191.       (void)(file); (void)(line);
    192. >     ret = malloc(num);
    193.   #endif
    194.   

crypto/mem.c:195:5: 
    193.   #endif
    194.   
    195. >     return ret;
    196.   }
    197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
    194.   
    195.       return ret;
    196. > }
    197.   
    198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
  201.   
  202.       FAILTEST();
  203.       if (ret != NULL)
                 ^
  204.           memset(ret, 0, num);
  205.       return ret;

crypto/mem.c:204:9: 
  202.       FAILTEST();
  203.       if (ret != NULL)
  204. >         memset(ret, 0, num);
  205.       return ret;
  206.   }

crypto/mem.c:205:5: 
  203.       if (ret != NULL)
  204.           memset(ret, 0, num);
  205. >     return ret;
  206.   }
  207.   

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
  204.           memset(ret, 0, num);
  205.       return ret;
  206. > }
  207.   
  208.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

ssl/ssl_lib.c:624:9: Taking false branch
622.   
623.       s = OPENSSL_zalloc(sizeof(*s));
624.       if (s == NULL)
               ^
625.           goto err;
626.   

ssl/ssl_lib.c:627:5: 
625.           goto err;
626.   
627. >     s->lock = CRYPTO_THREAD_lock_new();
628.       if (s->lock == NULL)
629.           goto err;

crypto/threads_pthread.c:19:1: start of procedure CRYPTO_THREAD_lock_new()
  17.   # endif
  18.   
  19. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  20.   {
  21.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:22:5: 
  20.   {
  21.   # ifdef USE_RWLOCK
  22. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  23.       if (lock == NULL)
  24.           return NULL;

crypto/mem.c:198:1: start of procedure CRYPTO_zalloc()
    196.   }
    197.   
    198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    199.   {
    200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
    198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    199.   {
    200. >     void *ret = CRYPTO_malloc(num, file, line);
    201.   
    202.       FAILTEST();

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
      168.   #endif
      169.   
      170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      171.   {
      172.       void *ret = NULL;

crypto/mem.c:172:5: 
      170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      171.   {
      172. >     void *ret = NULL;
      173.   
      174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
      172.       void *ret = NULL;
      173.   
      174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      175.           return malloc_impl(num, file, line);
      176.   

crypto/mem.c:177:9: Taking false branch
      175.           return malloc_impl(num, file, line);
      176.   
      177.       if (num == 0)
                     ^
      178.           return NULL;
      179.   

crypto/mem.c:181:5: 
      179.   
      180.       FAILTEST();
      181. >     allow_customize = 0;
      182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
      189.       }
      190.   #else
      191. >     (void)(file); (void)(line);
      192.       ret = malloc(num);
      193.   #endif

crypto/mem.c:191:19: 
      189.       }
      190.   #else
      191. >     (void)(file); (void)(line);
      192.       ret = malloc(num);
      193.   #endif

crypto/mem.c:192:5: 
      190.   #else
      191.       (void)(file); (void)(line);
      192. >     ret = malloc(num);
      193.   #endif
      194.   

crypto/mem.c:195:5: 
      193.   #endif
      194.   
      195. >     return ret;
      196.   }
      197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
      194.   
      195.       return ret;
      196. > }
      197.   
      198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
    201.   
    202.       FAILTEST();
    203.       if (ret != NULL)
                   ^
    204.           memset(ret, 0, num);
    205.       return ret;

crypto/mem.c:204:9: 
    202.       FAILTEST();
    203.       if (ret != NULL)
    204. >         memset(ret, 0, num);
    205.       return ret;
    206.   }

crypto/mem.c:205:5: 
    203.       if (ret != NULL)
    204.           memset(ret, 0, num);
    205. >     return ret;
    206.   }
    207.   

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
    204.           memset(ret, 0, num);
    205.       return ret;
    206. > }
    207.   
    208.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:23:9: Taking false branch
  21.   # ifdef USE_RWLOCK
  22.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  23.       if (lock == NULL)
                ^
  24.           return NULL;
  25.   

crypto/threads_pthread.c:26:9: Taking false branch
  24.           return NULL;
  25.   
  26.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  27.           OPENSSL_free(lock);
  28.           return NULL;

crypto/threads_pthread.c:48:5: 
  46.   # endif
  47.   
  48. >     return lock;
  49.   }
  50.   

crypto/threads_pthread.c:49:1: return from a call to CRYPTO_THREAD_lock_new
  47.   
  48.       return lock;
  49. > }
  50.   
  51.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

ssl/ssl_lib.c:628:9: Taking false branch
626.   
627.       s->lock = CRYPTO_THREAD_lock_new();
628.       if (s->lock == NULL)
               ^
629.           goto err;
630.   

ssl/ssl_lib.c:635:9: 
633.        * chained DRBG.
634.        */
635. >     if (RAND_get_rand_method() == RAND_OpenSSL()) {
636.           s->drbg = RAND_DRBG_new(NID_aes_128_ctr, RAND_DRBG_FLAG_CTR_USE_DF,
637.                                   RAND_DRBG_get0_global());

crypto/rand/rand_lib.c:250:1: start of procedure RAND_get_rand_method()
  248.   }
  249.   
  250. > const RAND_METHOD *RAND_get_rand_method(void)
  251.   {
  252.       const RAND_METHOD *tmp_meth = NULL;

crypto/rand/rand_lib.c:252:5: 
  250.   const RAND_METHOD *RAND_get_rand_method(void)
  251.   {
  252. >     const RAND_METHOD *tmp_meth = NULL;
  253.   
  254.       if (!RUN_ONCE(&rand_init, do_rand_init))

crypto/rand/rand_lib.c:254:10: 
  252.       const RAND_METHOD *tmp_meth = NULL;
  253.   
  254. >     if (!RUN_ONCE(&rand_init, do_rand_init))
  255.           return NULL;
  256.   

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

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

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

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

crypto/rand/rand_lib.c:254:10: Condition is false
  252.       const RAND_METHOD *tmp_meth = NULL;
  253.   
  254.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  255.           return NULL;
  256.   

crypto/rand/rand_lib.c:254:10: Taking true branch
  252.       const RAND_METHOD *tmp_meth = NULL;
  253.   
  254.       if (!RUN_ONCE(&rand_init, do_rand_init))
                  ^
  255.           return NULL;
  256.   

crypto/rand/rand_lib.c:255:9: 
  253.   
  254.       if (!RUN_ONCE(&rand_init, do_rand_init))
  255. >         return NULL;
  256.   
  257.       CRYPTO_THREAD_write_lock(rand_meth_lock);

crypto/rand/rand_lib.c:278:1: return from a call to RAND_get_rand_method
  276.       CRYPTO_THREAD_unlock(rand_meth_lock);
  277.       return tmp_meth;
  278. > }
  279.   
  280.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/drbg_lib.c:488:1: start of procedure RAND_OpenSSL()
  486.   };
  487.   
  488. > RAND_METHOD *RAND_OpenSSL(void)
  489.   {
  490.       return &rand_meth;

crypto/rand/drbg_lib.c:490:5: 
  488.   RAND_METHOD *RAND_OpenSSL(void)
  489.   {
  490. >     return &rand_meth;
  491.   }

crypto/rand/drbg_lib.c:491:1: return from a call to RAND_OpenSSL
  489.   {
  490.       return &rand_meth;
  491. > }

ssl/ssl_lib.c:635:9: Taking false branch
633.        * chained DRBG.
634.        */
635.       if (RAND_get_rand_method() == RAND_OpenSSL()) {
               ^
636.           s->drbg = RAND_DRBG_new(NID_aes_128_ctr, RAND_DRBG_FLAG_CTR_USE_DF,
637.                                   RAND_DRBG_get0_global());

ssl/ssl_lib.c:645:5: Skipping RECORD_LAYER_init(): empty list of specs
643.       }
644.   
645.       RECORD_LAYER_init(&s->rlayer, s);
           ^
646.   
647.       s->options = ctx->options;

SSL *SSL_new(SSL_CTX *ctx)
{
    SSL *s;
    if (ctx == NULL) {
        SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX);
        return (NULL);
    }
    if (ctx->method == NULL) {
        SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION);
        return (NULL);
    }
    s = OPENSSL_zalloc(sizeof(*s));
    if (s == NULL)
        goto err;
    s->lock = CRYPTO_THREAD_lock_new();
    if (s->lock == NULL)
        goto err;
    if (RAND_get_rand_method() == RAND_OpenSSL()) {
        s->drbg = RAND_DRBG_new(NID_aes_128_ctr, RAND_DRBG_FLAG_CTR_USE_DF,
                                RAND_DRBG_get0_global());
        if (s->drbg == NULL
            || RAND_DRBG_instantiate(s->drbg, NULL, 0) == 0) {
            CRYPTO_THREAD_lock_free(s->lock);
            goto err;
        }
    }
    RECORD_LAYER_init(&s->rlayer, s);
    s->options = ctx->options;
    s->dane.flags = ctx->dane.flags;
    s->min_proto_version = ctx->min_proto_version;
    s->max_proto_version = ctx->max_proto_version;
    s->mode = ctx->mode;
    s->max_cert_list = ctx->max_cert_list;
    s->references = 1;
    s->max_early_data = ctx->max_early_data;
    s->cert = ssl_cert_dup(ctx->cert);
    if (s->cert == NULL)
        goto err;
    RECORD_LAYER_set_read_ahead(&s->rlayer, ctx->read_ahead);
    s->msg_callback = ctx->msg_callback;
    s->msg_callback_arg = ctx->msg_callback_arg;
    s->verify_mode = ctx->verify_mode;
    s->not_resumable_session_cb = ctx->not_resumable_session_cb;
    s->record_padding_cb = ctx->record_padding_cb;
    s->record_padding_arg = ctx->record_padding_arg;
    s->block_padding = ctx->block_padding;
    s->sid_ctx_length = ctx->sid_ctx_length;
    if (!ossl_assert(s->sid_ctx_length <= sizeof s->sid_ctx))
        goto err;
    memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx));
    s->verify_callback = ctx->default_verify_callback;
    s->generate_session_id = ctx->generate_session_id;
    s->param = X509_VERIFY_PARAM_new();
    if (s->param == NULL)
        goto err;
    X509_VERIFY_PARAM_inherit(s->param, ctx->param);
    s->quiet_shutdown = ctx->quiet_shutdown;
    s->max_send_fragment = ctx->max_send_fragment;
    s->split_send_fragment = ctx->split_send_fragment;
    s->max_pipelines = ctx->max_pipelines;
    if (s->max_pipelines > 1)
        RECORD_LAYER_set_read_ahead(&s->rlayer, 1);
    if (ctx->default_read_buf_len > 0)
        SSL_set_default_read_buffer_len(s, ctx->default_read_buf_len);
    SSL_CTX_up_ref(ctx);
    s->ctx = ctx;
    s->ext.debug_cb = 0;
    s->ext.debug_arg = NULL;
    s->ext.ticket_expected = 0;
    s->ext.status_type = ctx->ext.status_type;
    s->ext.status_expected = 0;
    s->ext.ocsp.ids = NULL;
    s->ext.ocsp.exts = NULL;
    s->ext.ocsp.resp = NULL;
    s->ext.ocsp.resp_len = 0;
    SSL_CTX_up_ref(ctx);
    s->session_ctx = ctx;
#ifndef OPENSSL_NO_EC
    if (ctx->ext.ecpointformats) {
        s->ext.ecpointformats =
            OPENSSL_memdup(ctx->ext.ecpointformats,
                           ctx->ext.ecpointformats_len);
        if (!s->ext.ecpointformats)
            goto err;
        s->ext.ecpointformats_len =
            ctx->ext.ecpointformats_len;
    }
    if (ctx->ext.supportedgroups) {
        s->ext.supportedgroups =
            OPENSSL_memdup(ctx->ext.supportedgroups,
                           ctx->ext.supportedgroups_len
                                * sizeof(*ctx->ext.supportedgroups));
        if (!s->ext.supportedgroups)
            goto err;
        s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;
    }
#endif
#ifndef OPENSSL_NO_NEXTPROTONEG
    s->ext.npn = NULL;
#endif
    if (s->ctx->ext.alpn) {
        s->ext.alpn = OPENSSL_malloc(s->ctx->ext.alpn_len);
        if (s->ext.alpn == NULL)
            goto err;
        memcpy(s->ext.alpn, s->ctx->ext.alpn, s->ctx->ext.alpn_len);
        s->ext.alpn_len = s->ctx->ext.alpn_len;
    }
    s->verified_chain = NULL;
    s->verify_result = X509_V_OK;
    s->default_passwd_callback = ctx->default_passwd_callback;
    s->default_passwd_callback_userdata = ctx->default_passwd_callback_userdata;
    s->method = ctx->method;
    s->key_update = SSL_KEY_UPDATE_NONE;
    if (!s->method->ssl_new(s))
        goto err;
    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;
    if (!SSL_clear(s))
        goto err;
    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data))
        goto err;
#ifndef OPENSSL_NO_PSK
    s->psk_client_callback = ctx->psk_client_callback;
    s->psk_server_callback = ctx->psk_server_callback;
#endif
    s->psk_find_session_cb = ctx->psk_find_session_cb;
    s->psk_use_session_cb = ctx->psk_use_session_cb;
    s->job = NULL;
#ifndef OPENSSL_NO_CT
    if (!SSL_set_ct_validation_callback(s, ctx->ct_validation_callback,
                                        ctx->ct_validation_callback_arg))
        goto err;
#endif
    return s;
 err:
    SSL_free(s);
    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);
    return NULL;
}
['SSL *SSL_new(SSL_CTX *ctx)\n{\n    SSL *s;\n    if (ctx == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX);\n        return (NULL);\n    }\n    if (ctx->method == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION);\n        return (NULL);\n    }\n    s = OPENSSL_zalloc(sizeof(*s));\n    if (s == NULL)\n        goto err;\n    s->lock = CRYPTO_THREAD_lock_new();\n    if (s->lock == NULL)\n        goto err;\n    if (RAND_get_rand_method() == RAND_OpenSSL()) {\n        s->drbg = RAND_DRBG_new(NID_aes_128_ctr, RAND_DRBG_FLAG_CTR_USE_DF,\n                                RAND_DRBG_get0_global());\n        if (s->drbg == NULL\n            || RAND_DRBG_instantiate(s->drbg, NULL, 0) == 0) {\n            CRYPTO_THREAD_lock_free(s->lock);\n            goto err;\n        }\n    }\n    RECORD_LAYER_init(&s->rlayer, s);\n    s->options = ctx->options;\n    s->dane.flags = ctx->dane.flags;\n    s->min_proto_version = ctx->min_proto_version;\n    s->max_proto_version = ctx->max_proto_version;\n    s->mode = ctx->mode;\n    s->max_cert_list = ctx->max_cert_list;\n    s->references = 1;\n    s->max_early_data = ctx->max_early_data;\n    s->cert = ssl_cert_dup(ctx->cert);\n    if (s->cert == NULL)\n        goto err;\n    RECORD_LAYER_set_read_ahead(&s->rlayer, ctx->read_ahead);\n    s->msg_callback = ctx->msg_callback;\n    s->msg_callback_arg = ctx->msg_callback_arg;\n    s->verify_mode = ctx->verify_mode;\n    s->not_resumable_session_cb = ctx->not_resumable_session_cb;\n    s->record_padding_cb = ctx->record_padding_cb;\n    s->record_padding_arg = ctx->record_padding_arg;\n    s->block_padding = ctx->block_padding;\n    s->sid_ctx_length = ctx->sid_ctx_length;\n    if (!ossl_assert(s->sid_ctx_length <= sizeof s->sid_ctx))\n        goto err;\n    memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx));\n    s->verify_callback = ctx->default_verify_callback;\n    s->generate_session_id = ctx->generate_session_id;\n    s->param = X509_VERIFY_PARAM_new();\n    if (s->param == NULL)\n        goto err;\n    X509_VERIFY_PARAM_inherit(s->param, ctx->param);\n    s->quiet_shutdown = ctx->quiet_shutdown;\n    s->max_send_fragment = ctx->max_send_fragment;\n    s->split_send_fragment = ctx->split_send_fragment;\n    s->max_pipelines = ctx->max_pipelines;\n    if (s->max_pipelines > 1)\n        RECORD_LAYER_set_read_ahead(&s->rlayer, 1);\n    if (ctx->default_read_buf_len > 0)\n        SSL_set_default_read_buffer_len(s, ctx->default_read_buf_len);\n    SSL_CTX_up_ref(ctx);\n    s->ctx = ctx;\n    s->ext.debug_cb = 0;\n    s->ext.debug_arg = NULL;\n    s->ext.ticket_expected = 0;\n    s->ext.status_type = ctx->ext.status_type;\n    s->ext.status_expected = 0;\n    s->ext.ocsp.ids = NULL;\n    s->ext.ocsp.exts = NULL;\n    s->ext.ocsp.resp = NULL;\n    s->ext.ocsp.resp_len = 0;\n    SSL_CTX_up_ref(ctx);\n    s->session_ctx = ctx;\n#ifndef OPENSSL_NO_EC\n    if (ctx->ext.ecpointformats) {\n        s->ext.ecpointformats =\n            OPENSSL_memdup(ctx->ext.ecpointformats,\n                           ctx->ext.ecpointformats_len);\n        if (!s->ext.ecpointformats)\n            goto err;\n        s->ext.ecpointformats_len =\n            ctx->ext.ecpointformats_len;\n    }\n    if (ctx->ext.supportedgroups) {\n        s->ext.supportedgroups =\n            OPENSSL_memdup(ctx->ext.supportedgroups,\n                           ctx->ext.supportedgroups_len\n                                * sizeof(*ctx->ext.supportedgroups));\n        if (!s->ext.supportedgroups)\n            goto err;\n        s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;\n    }\n#endif\n#ifndef OPENSSL_NO_NEXTPROTONEG\n    s->ext.npn = NULL;\n#endif\n    if (s->ctx->ext.alpn) {\n        s->ext.alpn = OPENSSL_malloc(s->ctx->ext.alpn_len);\n        if (s->ext.alpn == NULL)\n            goto err;\n        memcpy(s->ext.alpn, s->ctx->ext.alpn, s->ctx->ext.alpn_len);\n        s->ext.alpn_len = s->ctx->ext.alpn_len;\n    }\n    s->verified_chain = NULL;\n    s->verify_result = X509_V_OK;\n    s->default_passwd_callback = ctx->default_passwd_callback;\n    s->default_passwd_callback_userdata = ctx->default_passwd_callback_userdata;\n    s->method = ctx->method;\n    s->key_update = SSL_KEY_UPDATE_NONE;\n    if (!s->method->ssl_new(s))\n        goto err;\n    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;\n    if (!SSL_clear(s))\n        goto err;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data))\n        goto err;\n#ifndef OPENSSL_NO_PSK\n    s->psk_client_callback = ctx->psk_client_callback;\n    s->psk_server_callback = ctx->psk_server_callback;\n#endif\n    s->psk_find_session_cb = ctx->psk_find_session_cb;\n    s->psk_use_session_cb = ctx->psk_use_session_cb;\n    s->job = NULL;\n#ifndef OPENSSL_NO_CT\n    if (!SSL_set_ct_validation_callback(s, ctx->ct_validation_callback,\n                                        ctx->ct_validation_callback_arg))\n        goto err;\n#endif\n    return s;\n err:\n    SSL_free(s);\n    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n    return NULL;\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n# ifdef USE_RWLOCK\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# else\n    pthread_mutexattr_t attr;\n    CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_mutex_t));\n    if (lock == NULL)\n        return NULL;\n    pthread_mutexattr_init(&attr);\n    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n    if (pthread_mutex_init(lock, &attr) != 0) {\n        pthread_mutexattr_destroy(&attr);\n        OPENSSL_free(lock);\n        return NULL;\n    }\n    pthread_mutexattr_destroy(&attr);\n# endif\n    return lock;\n}', 'const RAND_METHOD *RAND_get_rand_method(void)\n{\n    const RAND_METHOD *tmp_meth = NULL;\n    if (!RUN_ONCE(&rand_init, do_rand_init))\n        return NULL;\n    CRYPTO_THREAD_write_lock(rand_meth_lock);\n    if (default_RAND_meth == NULL) {\n#ifndef OPENSSL_NO_ENGINE\n        ENGINE *e;\n        if ((e = ENGINE_get_default_RAND()) != NULL\n                && (tmp_meth = ENGINE_get_RAND(e)) != NULL) {\n            funct_ref = e;\n            default_RAND_meth = tmp_meth;\n        } else {\n            ENGINE_finish(e);\n            default_RAND_meth = &rand_meth;\n        }\n#else\n        default_RAND_meth = &rand_meth;\n#endif\n    }\n    tmp_meth = default_RAND_meth;\n    CRYPTO_THREAD_unlock(rand_meth_lock);\n    return tmp_meth;\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}', 'RAND_METHOD *RAND_OpenSSL(void)\n{\n    return &rand_meth;\n}']