test/sslapitest.c:974: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `SSL_free`.
Showing all 19 steps of the trace


test/sslapitest.c:817:10: Call
815.       new_called = remove_called = 0;
816.   
817.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                ^
818.                                          TLS1_VERSION, TLS_MAX_VERSION,
819.                                          &sctx, &cctx, cert, privkey)))

test/ssltestlib.c:521:10: Call
  519.       SSL_CTX *clientctx = NULL;
  520.   
  521.       if (!TEST_ptr(serverctx = SSL_CTX_new(sm))
                  ^
  522.               || (cctx != NULL && !TEST_ptr(clientctx = SSL_CTX_new(cm))))
  523.           goto err;

ssl/ssl_lib.c:2995:21: Call
    2993.           goto err;
    2994.   
    2995.       ret->sessions = lh_SSL_SESSION_new(ssl_session_hash, ssl_session_cmp);
                                ^
    2996.       if (ret->sessions == NULL)
    2997.           goto err;

ssl/ssl_locl.h:732:1: Call
      730.   } TLSEXT_INDEX;
      731.   
      732. > DEFINE_LHASH_OF(SSL_SESSION);
      733.   /* Needed in ssl_cert.c */
      734.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:54:5: Assignment
        52.       ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);
        53.       ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);
        54.       ret->num_nodes = MIN_NODES / 2;
                  ^
        55.       ret->num_alloc_nodes = MIN_NODES;
        56.       ret->pmax = MIN_NODES / 2;

test/sslapitest.c:974:5: Call
972.                                          | SSL_SESS_CACHE_NO_INTERNAL_STORE);
973.   
974.       SSL_free(serverssl1);
           ^
975.       SSL_free(clientssl1);
976.       serverssl1 = clientssl1 = NULL;

ssl/ssl_lib.c:1124:1: Parameter `s->ctx->sessions->num_nodes`
  1122.   }
  1123.   
  1124. > void SSL_free(SSL *s)
  1125.   {
  1126.       int i;

ssl/ssl_lib.c:1197:5: Call
  1195.       RECORD_LAYER_release(&s->rlayer);
  1196.   
  1197.       SSL_CTX_free(s->ctx);
              ^
  1198.   
  1199.       ASYNC_WAIT_CTX_free(s->waitctx);

ssl/ssl_lib.c:3140:1: Parameter `a->sessions->num_nodes`
    3138.   }
    3139.   
    3140. > void SSL_CTX_free(SSL_CTX *a)
    3141.   {
    3142.       int i;

ssl/ssl_lib.c:3166:9: Call
    3164.        */
    3165.       if (a->sessions != NULL)
    3166.           SSL_CTX_flush_sessions(a, 0);
                    ^
    3167.   
    3168.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:1117:1: Parameter `s->sessions->num_nodes`
      1115.   IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1116.   
      1117. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
      1118.   {
      1119.       unsigned long i;

ssl/ssl_sess.c:1130:5: Call
      1128.       i = lh_SSL_SESSION_get_down_load(s->sessions);
      1129.       lh_SSL_SESSION_set_down_load(s->sessions, 0);
      1130.       lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);
                  ^
      1131.       lh_SSL_SESSION_set_down_load(s->sessions, i);
      1132.       CRYPTO_THREAD_unlock(s->lock);

ssl/ssl_sess.c:1115:1: Parameter `lh->num_nodes`
        1113.   }
        1114.   
        1115. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1116.   
        1117.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

ssl/ssl_sess.c:1115:1: Call
        1113.   }
        1114.   
        1115. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1116.   
        1117.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

crypto/lhash/lhash.c:198:1: Parameter `lh->num_nodes`
          196.   }
          197.   
          198. > void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
          199.   {
          200.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);

crypto/lhash/lhash.c:200:5: Call
          198.   void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
          199.   {
          200.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);
                     ^
          201.   }
          202.   

crypto/lhash/lhash.c:166:1: <LHS trace>
164.   }
165.   
166. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
167.                             OPENSSL_LH_DOALL_FUNC func,
168.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:166:1: Parameter `lh->num_nodes`
            164.   }
            165.   
            166. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
            167.                             OPENSSL_LH_DOALL_FUNC func,
            168.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:180:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `SSL_free` 
            178.        * memory leaks otherwise
            179.        */
            180.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                            ^
            181.           a = lh->b[i];
            182.           while (a != NULL) {

static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
                          OPENSSL_LH_DOALL_FUNC func,
                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)
{
    int i;
    OPENSSL_LH_NODE *a, *n;
    if (lh == NULL)
        return;
    for (i = lh->num_nodes - 1; i >= 0; i--) {
        a = lh->b[i];
        while (a != NULL) {
            n = a->next;
            if (use_arg)
                func_arg(a->data, arg);
            else
                func(a->data);
            a = n;
        }
    }
}
['static int execute_test_session(int maxprot, int use_int_cache,\n                                int use_ext_cache)\n{\n    SSL_CTX *sctx = NULL, *cctx = NULL;\n    SSL *serverssl1 = NULL, *clientssl1 = NULL;\n    SSL *serverssl2 = NULL, *clientssl2 = NULL;\n# ifndef OPENSSL_NO_TLS1_1\n    SSL *serverssl3 = NULL, *clientssl3 = NULL;\n# endif\n    SSL_SESSION *sess1 = NULL, *sess2 = NULL;\n    int testresult = 0;\n    new_called = remove_called = 0;\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),\n                                       TLS1_VERSION, TLS_MAX_VERSION,\n                                       &sctx, &cctx, cert, privkey)))\n        return 0;\n    SSL_CTX_set_min_proto_version(cctx, maxprot);\n    SSL_CTX_set_max_proto_version(cctx, maxprot);\n    if (use_ext_cache) {\n        SSL_CTX_sess_set_new_cb(cctx, new_session_cb);\n        SSL_CTX_sess_set_remove_cb(cctx, remove_session_cb);\n    }\n    if (use_int_cache) {\n        SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT);\n    } else {\n        SSL_CTX_set_session_cache_mode(cctx,\n                                       SSL_SESS_CACHE_CLIENT\n                                       | SSL_SESS_CACHE_NO_INTERNAL_STORE);\n    }\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1,\n                                      NULL, NULL))\n            || !TEST_true(create_ssl_connection(serverssl1, clientssl1,\n                                                SSL_ERROR_NONE))\n            || !TEST_ptr(sess1 = SSL_get1_session(clientssl1)))\n        goto end;\n    if (use_int_cache && !TEST_false(SSL_CTX_add_session(cctx, sess1)))\n        goto end;\n    if (use_ext_cache\n            && (!TEST_int_eq(new_called, 1) || !TEST_int_eq(remove_called, 0)))\n        goto end;\n    new_called = remove_called = 0;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,\n                                      &clientssl2, NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl2, sess1))\n            || !TEST_true(create_ssl_connection(serverssl2, clientssl2,\n                                                SSL_ERROR_NONE))\n            || !TEST_true(SSL_session_reused(clientssl2)))\n        goto end;\n    if (maxprot == TLS1_3_VERSION) {\n        if (use_ext_cache\n                && (!TEST_int_eq(new_called, 1)\n                    || !TEST_int_eq(remove_called, 1)))\n            goto end;\n    } else {\n        if (use_ext_cache\n                && (!TEST_int_eq(new_called, 0)\n                    || !TEST_int_eq(remove_called, 0)))\n            goto end;\n    }\n    SSL_SESSION_free(sess1);\n    if (!TEST_ptr(sess1 = SSL_get1_session(clientssl2)))\n        goto end;\n    shutdown_ssl_connection(serverssl2, clientssl2);\n    serverssl2 = clientssl2 = NULL;\n    new_called = remove_called = 0;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,\n                                      &clientssl2, NULL, NULL))\n            || !TEST_true(create_ssl_connection(serverssl2, clientssl2,\n                                                SSL_ERROR_NONE)))\n        goto end;\n    if (!TEST_ptr(sess2 = SSL_get1_session(clientssl2)))\n        goto end;\n    if (use_ext_cache\n            && (!TEST_int_eq(new_called, 1) || !TEST_int_eq(remove_called, 0)))\n        goto end;\n    new_called = remove_called = 0;\n    if (!TEST_true(SSL_set_session(clientssl2, sess1)))\n        goto end;\n    if (use_ext_cache\n            && (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))\n        goto end;\n    if (!TEST_ptr_eq(SSL_get_session(clientssl2), sess1))\n        goto end;\n    if (use_int_cache) {\n        if (!TEST_true(SSL_CTX_add_session(cctx, sess2))\n                || !TEST_true(SSL_CTX_remove_session(cctx, sess2)))\n            goto end;\n    }\n    new_called = remove_called = 0;\n    if (!TEST_false(SSL_CTX_remove_session(cctx, sess2)))\n        goto end;\n    if (use_ext_cache\n            && (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))\n        goto end;\n# if !defined(OPENSSL_NO_TLS1_1)\n    new_called = remove_called = 0;\n    SSL_CTX_set_max_proto_version(sctx, TLS1_1_VERSION);\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl3,\n                                      &clientssl3, NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl3, sess1))\n            || !TEST_false(create_ssl_connection(serverssl3, clientssl3,\n                                                 SSL_ERROR_NONE)))\n        goto end;\n    if (use_ext_cache\n            && (!TEST_int_eq(new_called, 0) || !TEST_int_eq(remove_called, 1)))\n        goto end;\n    if (use_int_cache && !TEST_true(SSL_CTX_add_session(cctx, sess2)))\n        goto end;\n# endif\n    if (use_ext_cache) {\n        SSL_CTX_sess_set_new_cb(cctx, NULL);\n        SSL_CTX_sess_set_remove_cb(cctx, NULL);\n        SSL_CTX_sess_set_new_cb(sctx, new_session_cb);\n        SSL_CTX_sess_set_remove_cb(sctx, remove_session_cb);\n        SSL_CTX_sess_set_get_cb(sctx, get_session_cb);\n        get_sess_val = NULL;\n    }\n    SSL_CTX_set_session_cache_mode(cctx, 0);\n    if (!use_int_cache)\n        SSL_CTX_set_session_cache_mode(sctx,\n                                       SSL_SESS_CACHE_SERVER\n                                       | SSL_SESS_CACHE_NO_INTERNAL_STORE);\n    SSL_free(serverssl1);\n    SSL_free(clientssl1);\n    serverssl1 = clientssl1 = NULL;\n    SSL_free(serverssl2);\n    SSL_free(clientssl2);\n    serverssl2 = clientssl2 = NULL;\n    SSL_SESSION_free(sess1);\n    sess1 = NULL;\n    SSL_SESSION_free(sess2);\n    sess2 = NULL;\n    SSL_CTX_set_max_proto_version(sctx, maxprot);\n    SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET);\n    new_called = remove_called = get_called = 0;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1,\n                                      NULL, NULL))\n            || !TEST_true(create_ssl_connection(serverssl1, clientssl1,\n                                                SSL_ERROR_NONE))\n            || !TEST_ptr(sess1 = SSL_get1_session(clientssl1))\n            || !TEST_ptr(sess2 = SSL_get1_session(serverssl1)))\n        goto end;\n    if (use_int_cache && !TEST_false(SSL_CTX_add_session(sctx, sess2)))\n        goto end;\n    if (use_ext_cache) {\n        SSL_SESSION *tmp = sess2;\n        if (!TEST_int_eq(new_called, 1)\n                || !TEST_int_eq(remove_called, 0)\n                || !TEST_int_eq(get_called, 0))\n            goto end;\n        if (use_int_cache) {\n            if (!TEST_ptr(tmp = SSL_SESSION_dup(sess2))\n                    || !TEST_true(SSL_CTX_remove_session(sctx, sess2)))\n                goto end;\n            SSL_SESSION_free(sess2);\n        }\n        sess2 = tmp;\n    }\n    new_called = remove_called = get_called = 0;\n    get_sess_val = sess2;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl2,\n                                      &clientssl2, NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl2, sess1))\n            || !TEST_true(create_ssl_connection(serverssl2, clientssl2,\n                                                SSL_ERROR_NONE))\n            || !TEST_true(SSL_session_reused(clientssl2)))\n        goto end;\n    if (use_ext_cache) {\n        if (!TEST_int_eq(remove_called, 0))\n            goto end;\n        if (maxprot == TLS1_3_VERSION) {\n            if (!TEST_int_eq(new_called, 1)\n                    || !TEST_int_eq(get_called, 0))\n                goto end;\n        } else {\n            if (!TEST_int_eq(new_called, 0)\n                    || !TEST_int_eq(get_called, 1))\n                goto end;\n        }\n    }\n    testresult = 1;\n end:\n    SSL_free(serverssl1);\n    SSL_free(clientssl1);\n    SSL_free(serverssl2);\n    SSL_free(clientssl2);\n# ifndef OPENSSL_NO_TLS1_1\n    SSL_free(serverssl3);\n    SSL_free(clientssl3);\n# endif\n    SSL_SESSION_free(sess1);\n    SSL_SESSION_free(sess2);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm,\n                        int min_proto_version, int max_proto_version,\n                        SSL_CTX **sctx, SSL_CTX **cctx, char *certfile,\n                        char *privkeyfile)\n{\n    SSL_CTX *serverctx = NULL;\n    SSL_CTX *clientctx = NULL;\n    if (!TEST_ptr(serverctx = SSL_CTX_new(sm))\n            || (cctx != NULL && !TEST_ptr(clientctx = SSL_CTX_new(cm))))\n        goto err;\n    if ((min_proto_version > 0\n         && !TEST_true(SSL_CTX_set_min_proto_version(serverctx,\n                                                     min_proto_version)))\n        || (max_proto_version > 0\n            && !TEST_true(SSL_CTX_set_max_proto_version(serverctx,\n                                                        max_proto_version))))\n        goto err;\n    if (clientctx != NULL\n        && ((min_proto_version > 0\n             && !TEST_true(SSL_CTX_set_min_proto_version(serverctx,\n                                                         min_proto_version)))\n            || (max_proto_version > 0\n                && !TEST_true(SSL_CTX_set_max_proto_version(serverctx,\n                                                            max_proto_version)))))\n        goto err;\n    if (!TEST_int_eq(SSL_CTX_use_certificate_file(serverctx, certfile,\n                                                  SSL_FILETYPE_PEM), 1)\n            || !TEST_int_eq(SSL_CTX_use_PrivateKey_file(serverctx, privkeyfile,\n                                                        SSL_FILETYPE_PEM), 1)\n            || !TEST_int_eq(SSL_CTX_check_private_key(serverctx), 1))\n        goto err;\n#ifndef OPENSSL_NO_DH\n    SSL_CTX_set_dh_auto(serverctx, 1);\n#endif\n    *sctx = serverctx;\n    if (cctx != NULL)\n        *cctx = clientctx;\n    return 1;\n err:\n    SSL_CTX_free(serverctx);\n    SSL_CTX_free(clientctx);\n    return 0;\n}', 'SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)\n{\n    SSL_CTX *ret = NULL;\n    if (meth == NULL) {\n        SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_NULL_SSL_METHOD_PASSED);\n        return NULL;\n    }\n    if (!OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL))\n        return NULL;\n    if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) {\n        SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);\n        goto err;\n    }\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL)\n        goto err;\n    ret->method = meth;\n    ret->min_proto_version = 0;\n    ret->max_proto_version = 0;\n    ret->session_cache_mode = SSL_SESS_CACHE_SERVER;\n    ret->session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT;\n    ret->session_timeout = meth->get_timeout();\n    ret->references = 1;\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        SSLerr(SSL_F_SSL_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    ret->max_cert_list = SSL_MAX_CERT_LIST_DEFAULT;\n    ret->verify_mode = SSL_VERIFY_NONE;\n    if ((ret->cert = ssl_cert_new()) == NULL)\n        goto err;\n    ret->sessions = lh_SSL_SESSION_new(ssl_session_hash, ssl_session_cmp);\n    if (ret->sessions == NULL)\n        goto err;\n    ret->cert_store = X509_STORE_new();\n    if (ret->cert_store == NULL)\n        goto err;\n#ifndef OPENSSL_NO_CT\n    ret->ctlog_store = CTLOG_STORE_new();\n    if (ret->ctlog_store == NULL)\n        goto err;\n#endif\n    if (!SSL_CTX_set_ciphersuites(ret, TLS_DEFAULT_CIPHERSUITES))\n        goto err;\n    if (!ssl_create_cipher_list(ret->method,\n                                ret->tls13_ciphersuites,\n                                &ret->cipher_list, &ret->cipher_list_by_id,\n                                SSL_DEFAULT_CIPHER_LIST, ret->cert)\n        || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) {\n        SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_LIBRARY_HAS_NO_CIPHERS);\n        goto err2;\n    }\n    ret->param = X509_VERIFY_PARAM_new();\n    if (ret->param == NULL)\n        goto err;\n    if ((ret->md5 = EVP_get_digestbyname("ssl3-md5")) == NULL) {\n        SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES);\n        goto err2;\n    }\n    if ((ret->sha1 = EVP_get_digestbyname("ssl3-sha1")) == NULL) {\n        SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES);\n        goto err2;\n    }\n    if ((ret->ca_names = sk_X509_NAME_new_null()) == NULL)\n        goto err;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data))\n        goto err;\n    if ((ret->ext.secure = OPENSSL_secure_zalloc(sizeof(*ret->ext.secure))) == NULL)\n        goto err;\n    if (!(meth->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS))\n        ret->comp_methods = SSL_COMP_get_compression_methods();\n    ret->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;\n    ret->split_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;\n    if ((RAND_bytes(ret->ext.tick_key_name,\n                    sizeof(ret->ext.tick_key_name)) <= 0)\n        || (RAND_bytes(ret->ext.secure->tick_hmac_key,\n                       sizeof(ret->ext.secure->tick_hmac_key)) <= 0)\n        || (RAND_bytes(ret->ext.secure->tick_aes_key,\n                       sizeof(ret->ext.secure->tick_aes_key)) <= 0))\n        ret->options |= SSL_OP_NO_TICKET;\n    if (RAND_bytes(ret->ext.cookie_hmac_key,\n                   sizeof(ret->ext.cookie_hmac_key)) <= 0)\n        goto err;\n#ifndef OPENSSL_NO_SRP\n    if (!SSL_CTX_SRP_CTX_init(ret))\n        goto err;\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO\n#  define eng_strx(x)     #x\n#  define eng_str(x)      eng_strx(x)\n    {\n        ENGINE *eng;\n        eng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));\n        if (!eng) {\n            ERR_clear_error();\n            ENGINE_load_builtin_engines();\n            eng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));\n        }\n        if (!eng || !SSL_CTX_set_client_cert_engine(ret, eng))\n            ERR_clear_error();\n    }\n# endif\n#endif\n    ret->options |= SSL_OP_LEGACY_SERVER_CONNECT;\n    ret->options |= SSL_OP_NO_COMPRESSION | SSL_OP_ENABLE_MIDDLEBOX_COMPAT;\n    ret->ext.status_type = TLSEXT_STATUSTYPE_nothing;\n    ret->max_early_data = 0;\n    ssl_ctx_system_config(ret);\n    return ret;\n err:\n    SSLerr(SSL_F_SSL_CTX_NEW, ERR_R_MALLOC_FAILURE);\n err2:\n    SSL_CTX_free(ret);\n    return NULL;\n}', 'DEFINE_LHASH_OF(SSL_SESSION)', 'OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c)\n{\n    OPENSSL_LHASH *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)\n        return NULL;\n    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);\n    ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);\n    ret->num_nodes = MIN_NODES / 2;\n    ret->num_alloc_nodes = MIN_NODES;\n    ret->pmax = MIN_NODES / 2;\n    ret->up_load = UP_LOAD;\n    ret->down_load = DOWN_LOAD;\n    return ret;\nerr:\n    OPENSSL_free(ret->b);\n    OPENSSL_free(ret);\n    return NULL;\n}', 'void SSL_free(SSL *s)\n{\n    int i;\n    if (s == NULL)\n        return;\n    CRYPTO_DOWN_REF(&s->references, &i, s->lock);\n    REF_PRINT_COUNT("SSL", s);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(s->param);\n    dane_final(&s->dane);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n    ssl_free_wbio_buffer(s);\n    BIO_free_all(s->wbio);\n    BIO_free_all(s->rbio);\n    BUF_MEM_free(s->init_buf);\n    sk_SSL_CIPHER_free(s->cipher_list);\n    sk_SSL_CIPHER_free(s->cipher_list_by_id);\n    sk_SSL_CIPHER_free(s->tls13_ciphersuites);\n    if (s->session != NULL) {\n        ssl_clear_bad_session(s);\n        SSL_SESSION_free(s->session);\n    }\n    SSL_SESSION_free(s->psksession);\n    OPENSSL_free(s->psksession_id);\n    clear_ciphers(s);\n    ssl_cert_free(s->cert);\n    OPENSSL_free(s->ext.hostname);\n    SSL_CTX_free(s->session_ctx);\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(s->ext.ecpointformats);\n    OPENSSL_free(s->ext.supportedgroups);\n#endif\n    sk_X509_EXTENSION_pop_free(s->ext.ocsp.exts, X509_EXTENSION_free);\n#ifndef OPENSSL_NO_OCSP\n    sk_OCSP_RESPID_pop_free(s->ext.ocsp.ids, OCSP_RESPID_free);\n#endif\n#ifndef OPENSSL_NO_CT\n    SCT_LIST_free(s->scts);\n    OPENSSL_free(s->ext.scts);\n#endif\n    OPENSSL_free(s->ext.ocsp.resp);\n    OPENSSL_free(s->ext.alpn);\n    OPENSSL_free(s->ext.tls13_cookie);\n    OPENSSL_free(s->clienthello);\n    OPENSSL_free(s->pha_context);\n    EVP_MD_CTX_free(s->pha_dgst);\n    sk_X509_NAME_pop_free(s->ca_names, X509_NAME_free);\n    sk_X509_pop_free(s->verified_chain, X509_free);\n    if (s->method != NULL)\n        s->method->ssl_free(s);\n    RECORD_LAYER_release(&s->rlayer);\n    SSL_CTX_free(s->ctx);\n    ASYNC_WAIT_CTX_free(s->waitctx);\n#if !defined(OPENSSL_NO_NEXTPROTONEG)\n    OPENSSL_free(s->ext.npn);\n#endif\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles);\n#endif\n    CRYPTO_THREAD_lock_free(s->lock);\n    OPENSSL_free(s);\n}', 'void SSL_CTX_free(SSL_CTX *a)\n{\n    int i;\n    if (a == NULL)\n        return;\n    CRYPTO_DOWN_REF(&a->references, &i, a->lock);\n    REF_PRINT_COUNT("SSL_CTX", a);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(a->param);\n    dane_ctx_final(&a->dane);\n    if (a->sessions != NULL)\n        SSL_CTX_flush_sessions(a, 0);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);\n    lh_SSL_SESSION_free(a->sessions);\n    X509_STORE_free(a->cert_store);\n#ifndef OPENSSL_NO_CT\n    CTLOG_STORE_free(a->ctlog_store);\n#endif\n    sk_SSL_CIPHER_free(a->cipher_list);\n    sk_SSL_CIPHER_free(a->cipher_list_by_id);\n    sk_SSL_CIPHER_free(a->tls13_ciphersuites);\n    ssl_cert_free(a->cert);\n    sk_X509_NAME_pop_free(a->ca_names, X509_NAME_free);\n    sk_X509_pop_free(a->extra_certs, X509_free);\n    a->comp_methods = NULL;\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles);\n#endif\n#ifndef OPENSSL_NO_SRP\n    SSL_CTX_SRP_CTX_free(a);\n#endif\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(a->client_cert_engine);\n#endif\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(a->ext.ecpointformats);\n    OPENSSL_free(a->ext.supportedgroups);\n#endif\n    OPENSSL_free(a->ext.alpn);\n    OPENSSL_secure_free(a->ext.secure);\n    CRYPTO_THREAD_lock_free(a->lock);\n    OPENSSL_free(a);\n}', 'void SSL_CTX_flush_sessions(SSL_CTX *s, long t)\n{\n    unsigned long i;\n    TIMEOUT_PARAM tp;\n    tp.ctx = s;\n    tp.cache = s->sessions;\n    if (tp.cache == NULL)\n        return;\n    tp.time = t;\n    CRYPTO_THREAD_write_lock(s->lock);\n    i = lh_SSL_SESSION_get_down_load(s->sessions);\n    lh_SSL_SESSION_set_down_load(s->sessions, 0);\n    lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);\n    lh_SSL_SESSION_set_down_load(s->sessions, i);\n    CRYPTO_THREAD_unlock(s->lock);\n}', 'IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM)', 'void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)\n{\n    doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);\n}', 'static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,\n                          OPENSSL_LH_DOALL_FUNC func,\n                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)\n{\n    int i;\n    OPENSSL_LH_NODE *a, *n;\n    if (lh == NULL)\n        return;\n    for (i = lh->num_nodes - 1; i >= 0; i--) {\n        a = lh->b[i];\n        while (a != NULL) {\n            n = a->next;\n            if (use_arg)\n                func_arg(a->data, arg);\n            else\n                func(a->data);\n            a = n;\n        }\n    }\n}']