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


test/sslapitest.c:1486:1: Parameter `(*serverssl)->ctx->sessions->num_nodes`
1484.    * error.
1485.    */
1486. > static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
1487.                                   SSL **serverssl, SSL_SESSION **sess, int idx)
1488.   {

test/sslapitest.c:1570:5: Call
1568.       SSL_shutdown(*clientssl);
1569.       SSL_shutdown(*serverssl);
1570.       SSL_free(*serverssl);
            ^
1571.       SSL_free(*clientssl);
1572.       *serverssl = *clientssl = NULL;

ssl/ssl_lib.c:1132:1: Parameter `s->ctx->sessions->num_nodes`
  1130.   }
  1131.   
  1132. > void SSL_free(SSL *s)
  1133.   {
  1134.       int i;

ssl/ssl_lib.c:1204:5: Call
  1202.       RECORD_LAYER_release(&s->rlayer);
  1203.   
  1204.       SSL_CTX_free(s->ctx);
              ^
  1205.   
  1206.       ASYNC_WAIT_CTX_free(s->waitctx);

ssl/ssl_lib.c:3017:1: Parameter `a->sessions->num_nodes`
    3015.   }
    3016.   
    3017. > void SSL_CTX_free(SSL_CTX *a)
    3018.   {
    3019.       int i;

ssl/ssl_lib.c:3043:9: Call
    3041.        */
    3042.       if (a->sessions != NULL)
    3043.           SSL_CTX_flush_sessions(a, 0);
                    ^
    3044.   
    3045.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:1102:1: Parameter `s->sessions->num_nodes`
      1100.   IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1101.   
      1102. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
      1103.   {
      1104.       unsigned long i;

ssl/ssl_sess.c:1115:5: Call
      1113.       i = lh_SSL_SESSION_get_down_load(s->sessions);
      1114.       lh_SSL_SESSION_set_down_load(s->sessions, 0);
      1115.       lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);
                  ^
      1116.       lh_SSL_SESSION_set_down_load(s->sessions, i);
      1117.       CRYPTO_THREAD_unlock(s->lock);

ssl/ssl_sess.c:1100:1: Parameter `lh->num_nodes`
        1098.   }
        1099.   
        1100. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1101.   
        1102.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

ssl/ssl_sess.c:1100:1: Call
        1098.   }
        1099.   
        1100. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1101.   
        1102.   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 setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,\n                                SSL **serverssl, SSL_SESSION **sess, int idx)\n{\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),\n                                       TLS_client_method(), sctx,\n                                       cctx, cert, privkey)))\n        return 0;\n    if (idx == 1) {\n        SSL_CTX_set_read_ahead(*cctx, 1);\n        SSL_CTX_set_read_ahead(*sctx, 1);\n    } else if (idx == 2) {\n        SSL_CTX_set_psk_use_session_callback(*cctx, use_session_cb);\n        SSL_CTX_set_psk_find_session_callback(*sctx, find_session_cb);\n        use_session_cb_cnt = 0;\n        find_session_cb_cnt = 0;\n        srvid = pskid;\n    }\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, clientssl,\n                                      NULL, NULL)))\n        return 0;\n    if (idx == 1\n            && !TEST_true(SSL_set_tlsext_host_name(*clientssl, "localhost")))\n        return 0;\n    if (idx == 2) {\n        const SSL_CIPHER *cipher = NULL;\n        const unsigned char key[] = {\n            0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,\n            0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,\n            0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,\n            0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,\n            0x2c, 0x2d, 0x2e, 0x2f\n        };\n        cipher = SSL_CIPHER_find(*clientssl, TLS13_AES_256_GCM_SHA384_BYTES);\n        clientpsk = SSL_SESSION_new();\n        if (!TEST_ptr(clientpsk)\n                || !TEST_ptr(cipher)\n                || !TEST_true(SSL_SESSION_set1_master_key(clientpsk, key,\n                                                          sizeof(key)))\n                || !TEST_true(SSL_SESSION_set_cipher(clientpsk, cipher))\n                || !TEST_true(\n                        SSL_SESSION_set_protocol_version(clientpsk,\n                                                         TLS1_3_VERSION))\n                || !TEST_true(SSL_SESSION_set_max_early_data(clientpsk,\n                                                             0x100))\n                || !TEST_true(SSL_SESSION_up_ref(clientpsk))) {\n            SSL_SESSION_free(clientpsk);\n            clientpsk = NULL;\n            return 0;\n        }\n        serverpsk = clientpsk;\n        if (sess != NULL)\n            *sess = clientpsk;\n        return 1;\n    }\n    if (sess == NULL)\n        return 1;\n    if (!TEST_true(create_ssl_connection(*serverssl, *clientssl,\n                                         SSL_ERROR_NONE)))\n        return 0;\n    *sess = SSL_get1_session(*clientssl);\n    SSL_shutdown(*clientssl);\n    SSL_shutdown(*serverssl);\n    SSL_free(*serverssl);\n    SSL_free(*clientssl);\n    *serverssl = *clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl,\n                                      clientssl, NULL, NULL))\n            || !TEST_true(SSL_set_session(*clientssl, *sess)))\n        return 0;\n    return 1;\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    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    RAND_DRBG_free(s->drbg);\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    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    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}']