test/sslapitest.c:4586: error: NULL_DEREFERENCE
  pointer `sctx2` last assigned on line 4387 could be null and is dereferenced by call to `SSL_CTX_free()` at line 4586, column 5.
Showing all 43 steps of the trace


test/sslapitest.c:4385:1: start of procedure test_custom_exts()
4383.    * Test 4: New style callbacks in TLSv1.3. Extensions in CH, SH, EE, Cert + NST
4384.    */
4385. > static int test_custom_exts(int tst)
4386.   {
4387.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;

test/sslapitest.c:4387:5: 
4385.   static int test_custom_exts(int tst)
4386.   {
4387. >     SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4388.       SSL *clientssl = NULL, *serverssl = NULL;
4389.       int testresult = 0;

test/sslapitest.c:4388:5: 
4386.   {
4387.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4388. >     SSL *clientssl = NULL, *serverssl = NULL;
4389.       int testresult = 0;
4390.       static int server = 1;

test/sslapitest.c:4389:5: 
4387.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4388.       SSL *clientssl = NULL, *serverssl = NULL;
4389. >     int testresult = 0;
4390.       static int server = 1;
4391.       static int client = 0;

test/sslapitest.c:4390:5: 
4388.       SSL *clientssl = NULL, *serverssl = NULL;
4389.       int testresult = 0;
4390. >     static int server = 1;
4391.       static int client = 0;
4392.       SSL_SESSION *sess = NULL;

test/sslapitest.c:4391:5: 
4389.       int testresult = 0;
4390.       static int server = 1;
4391. >     static int client = 0;
4392.       SSL_SESSION *sess = NULL;
4393.       unsigned int context;

test/sslapitest.c:4392:5: 
4390.       static int server = 1;
4391.       static int client = 0;
4392. >     SSL_SESSION *sess = NULL;
4393.       unsigned int context;
4394.   

test/sslapitest.c:4402:5: 
4400.   
4401.       /* Reset callback counters */
4402. >     clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;
4403.       clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;
4404.       snicb = 0;

test/sslapitest.c:4403:5: 
4401.       /* Reset callback counters */
4402.       clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;
4403. >     clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;
4404.       snicb = 0;
4405.   

test/sslapitest.c:4404:5: 
4402.       clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;
4403.       clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;
4404. >     snicb = 0;
4405.   
4406.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),

test/sslapitest.c:4406:10: 
4404.       snicb = 0;
4405.   
4406. >     if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
4407.                                          TLS1_VERSION, 0,
4408.                                          &sctx, &cctx, cert, privkey)))

ssl/methods.c:49:1: start of procedure TLS_server_method()
  47.    * TLS/SSLv3 server methods
  48.    */
  49. > IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
  50.                           TLS_server_method,
  51.                           ossl_statem_accept,

ssl/methods.c:49:1: return from a call to TLS_server_method
  47.    * TLS/SSLv3 server methods
  48.    */
  49. > IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
  50.                           TLS_server_method,
  51.                           ossl_statem_accept,

ssl/methods.c:82:1: start of procedure TLS_client_method()
  80.    * TLS/SSLv3 client methods
  81.    */
  82. > IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
  83.                           TLS_client_method,
  84.                           ssl_undefined_function,

ssl/methods.c:82:1: return from a call to TLS_client_method
  80.    * TLS/SSLv3 client methods
  81.    */
  82. > IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
  83.                           TLS_client_method,
  84.                           ssl_undefined_function,

test/sslapitest.c:4406:10: Condition is false
4404.       snicb = 0;
4405.   
4406.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4407.                                          TLS1_VERSION, 0,
4408.                                          &sctx, &cctx, cert, privkey)))

test/testutil/tests.c:260:1: start of procedure test_true()
  258.   }
  259.   
  260. > int test_true(const char *file, int line, const char *s, int b)
  261.   {
  262.       if (b)

test/testutil/tests.c:262:9: Taking false branch
  260.   int test_true(const char *file, int line, const char *s, int b)
  261.   {
  262.       if (b)
                 ^
  263.           return 1;
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");

test/testutil/tests.c:264:5: Skipping test_fail_message(): empty list of specs
  262.       if (b)
  263.           return 1;
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
             ^
  265.       return 0;
  266.   }

test/testutil/tests.c:265:5: 
  263.           return 1;
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  265. >     return 0;
  266.   }
  267.   

test/testutil/tests.c:266:1: return from a call to test_true
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  265.       return 0;
  266. > }
  267.   
  268.   int test_false(const char *file, int line, const char *s, int b)

test/sslapitest.c:4406:10: Taking true branch
4404.       snicb = 0;
4405.   
4406.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4407.                                          TLS1_VERSION, 0,
4408.                                          &sctx, &cctx, cert, privkey)))

test/sslapitest.c:4582:1: 
4580.       testresult = 1;
4581.   
4582. > end:
4583.       SSL_SESSION_free(sess);
4584.       SSL_free(serverssl);

test/sslapitest.c:4583:5: 
4581.   
4582.   end:
4583. >     SSL_SESSION_free(sess);
4584.       SSL_free(serverssl);
4585.       SSL_free(clientssl);

ssl/ssl_sess.c:747:1: start of procedure SSL_SESSION_free()
  745.   }
  746.   
  747. > void SSL_SESSION_free(SSL_SESSION *ss)
  748.   {
  749.       int i;

ssl/ssl_sess.c:751:9: Taking true branch
  749.       int i;
  750.   
  751.       if (ss == NULL)
                 ^
  752.           return;
  753.       CRYPTO_DOWN_REF(&ss->references, &i, ss->lock);

ssl/ssl_sess.c:752:9: 
  750.   
  751.       if (ss == NULL)
  752. >         return;
  753.       CRYPTO_DOWN_REF(&ss->references, &i, ss->lock);
  754.       REF_PRINT_COUNT("SSL_SESSION", ss);

ssl/ssl_sess.c:778:1: return from a call to SSL_SESSION_free
  776.       CRYPTO_THREAD_lock_free(ss->lock);
  777.       OPENSSL_clear_free(ss, sizeof(*ss));
  778. > }
  779.   
  780.   int SSL_SESSION_up_ref(SSL_SESSION *ss)

test/sslapitest.c:4584:5: Skipping SSL_free(): empty list of specs
4582.   end:
4583.       SSL_SESSION_free(sess);
4584.       SSL_free(serverssl);
            ^
4585.       SSL_free(clientssl);
4586.       SSL_CTX_free(sctx2);

test/sslapitest.c:4585:5: Skipping SSL_free(): empty list of specs
4583.       SSL_SESSION_free(sess);
4584.       SSL_free(serverssl);
4585.       SSL_free(clientssl);
            ^
4586.       SSL_CTX_free(sctx2);
4587.       SSL_CTX_free(sctx);

test/sslapitest.c:4586:5: 
4584.       SSL_free(serverssl);
4585.       SSL_free(clientssl);
4586. >     SSL_CTX_free(sctx2);
4587.       SSL_CTX_free(sctx);
4588.       SSL_CTX_free(cctx);

ssl/ssl_lib.c:3240:1: start of procedure SSL_CTX_free()
  3238.   }
  3239.   
  3240. > void SSL_CTX_free(SSL_CTX *a)
  3241.   {
  3242.       int i;

ssl/ssl_lib.c:3244:9: Taking false branch
  3242.       int i;
  3243.   
  3244.       if (a == NULL)
                  ^
  3245.           return;
  3246.   

ssl/ssl_lib.c:3247:5: 
  3245.           return;
  3246.   
  3247. >     CRYPTO_DOWN_REF(&a->references, &i, a->lock);
  3248.       REF_PRINT_COUNT("SSL_CTX", a);
  3249.       if (i > 0)

include/internal/refcount.h:49:1: start of procedure CRYPTO_DOWN_REF()
    47.    * otherwise imply an acquire fence. Hence conditional acquire fence...
    48.    */
    49. > static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)
    50.   {
    51.       *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;

include/internal/refcount.h:51:5: 
    49.   static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)
    50.   {
    51. >     *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;
    52.       if (*ret == 0)
    53.           atomic_thread_fence(memory_order_acquire);

include/internal/refcount.h:52:9: Taking true branch
    50.   {
    51.       *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;
    52.       if (*ret == 0)
                  ^
    53.           atomic_thread_fence(memory_order_acquire);
    54.       return 1;

include/internal/refcount.h:53:9: Skipping __c11_atomic_thread_fence(): method has no implementation
    51.       *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;
    52.       if (*ret == 0)
    53.           atomic_thread_fence(memory_order_acquire);
                  ^
    54.       return 1;
    55.   }

include/internal/refcount.h:54:5: 
    52.       if (*ret == 0)
    53.           atomic_thread_fence(memory_order_acquire);
    54. >     return 1;
    55.   }
    56.   

include/internal/refcount.h:55:1: return from a call to CRYPTO_DOWN_REF
    53.           atomic_thread_fence(memory_order_acquire);
    54.       return 1;
    55. > }
    56.   
    57.   #  elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0

ssl/ssl_lib.c:3249:9: Taking true branch
  3247.       CRYPTO_DOWN_REF(&a->references, &i, a->lock);
  3248.       REF_PRINT_COUNT("SSL_CTX", a);
  3249.       if (i > 0)
                  ^
  3250.           return;
  3251.       REF_ASSERT_ISNT(i < 0);

ssl/ssl_lib.c:3250:9: 
  3248.       REF_PRINT_COUNT("SSL_CTX", a);
  3249.       if (i > 0)
  3250. >         return;
  3251.       REF_ASSERT_ISNT(i < 0);
  3252.   

ssl/ssl_lib.c:3302:1: return from a call to SSL_CTX_free
  3300.   
  3301.       OPENSSL_free(a);
  3302. > }
  3303.   
  3304.   void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb)

static int test_custom_exts(int tst)
{
    SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
    SSL *clientssl = NULL, *serverssl = NULL;
    int testresult = 0;
    static int server = 1;
    static int client = 0;
    SSL_SESSION *sess = NULL;
    unsigned int context;
#if defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_TLS1_3)
    if (tst < 3)
        return 1;
#endif
    clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;
    clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;
    snicb = 0;
    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                                       TLS1_VERSION, 0,
                                       &sctx, &cctx, cert, privkey)))
        goto end;
    if (tst == 2
            && !TEST_true(create_ssl_ctx_pair(TLS_server_method(), NULL,
                                              TLS1_VERSION, 0,
                                              &sctx2, NULL, cert, privkey)))
        goto end;
    if (tst < 3) {
        SSL_CTX_set_options(cctx, SSL_OP_NO_TLSv1_3);
        SSL_CTX_set_options(sctx, SSL_OP_NO_TLSv1_3);
        if (sctx2 != NULL)
            SSL_CTX_set_options(sctx2, SSL_OP_NO_TLSv1_3);
    }
    if (tst == 4) {
        context = SSL_EXT_CLIENT_HELLO
                  | SSL_EXT_TLS1_2_SERVER_HELLO
                  | SSL_EXT_TLS1_3_SERVER_HELLO
                  | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS
                  | SSL_EXT_TLS1_3_CERTIFICATE
                  | SSL_EXT_TLS1_3_NEW_SESSION_TICKET;
    } else {
        context = SSL_EXT_CLIENT_HELLO
                  | SSL_EXT_TLS1_2_SERVER_HELLO
                  | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS;
    }
    if (tst == 0) {
        if (!TEST_true(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,
                                                     old_add_cb, old_free_cb,
                                                     &client, old_parse_cb,
                                                     &client)))
            goto end;
    } else {
        if (!TEST_true(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1, context,
                                              new_add_cb, new_free_cb,
                                              &client, new_parse_cb, &client)))
            goto end;
    }
    if (!TEST_false(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,
                                                  old_add_cb, old_free_cb,
                                                  &client, old_parse_cb,
                                                  &client))
            || !TEST_false(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1,
                                                  context, new_add_cb,
                                                  new_free_cb, &client,
                                                  new_parse_cb, &client)))
        goto end;
    if (tst == 0) {
        if (!TEST_true(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,
                                                     old_add_cb, old_free_cb,
                                                     &server, old_parse_cb,
                                                     &server)))
            goto end;
    } else {
        if (!TEST_true(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1, context,
                                              new_add_cb, new_free_cb,
                                              &server, new_parse_cb, &server)))
            goto end;
        if (sctx2 != NULL
                && !TEST_true(SSL_CTX_add_custom_ext(sctx2, TEST_EXT_TYPE1,
                                                     context, new_add_cb,
                                                     new_free_cb, &server,
                                                     new_parse_cb, &server)))
            goto end;
    }
    if (!TEST_false(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,
                                                  old_add_cb, old_free_cb,
                                                  &server, old_parse_cb,
                                                  &server))
            || !TEST_false(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1,
                                                  context, new_add_cb,
                                                  new_free_cb, &server,
                                                  new_parse_cb, &server)))
        goto end;
    if (tst == 2) {
        if (!TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx, sni_cb))
                || !TEST_true(SSL_CTX_set_tlsext_servername_arg(sctx, sctx2)))
            goto end;
    }
    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
                                      &clientssl, NULL, NULL))
            || !TEST_true(create_ssl_connection(serverssl, clientssl,
                                                SSL_ERROR_NONE)))
        goto end;
    if (tst == 0) {
        if (clntaddoldcb != 1
                || clntparseoldcb != 1
                || srvaddoldcb != 1
                || srvparseoldcb != 1)
            goto end;
    } else if (tst == 1 || tst == 2 || tst == 3) {
        if (clntaddnewcb != 1
                || clntparsenewcb != 1
                || srvaddnewcb != 1
                || srvparsenewcb != 1
                || (tst != 2 && snicb != 0)
                || (tst == 2 && snicb != 1))
            goto end;
    } else {
        if (clntaddnewcb != 1
                || clntparsenewcb != 5
                || srvaddnewcb != 5
                || srvparsenewcb != 1)
            goto end;
    }
    sess = SSL_get1_session(clientssl);
    SSL_shutdown(clientssl);
    SSL_shutdown(serverssl);
    SSL_free(serverssl);
    SSL_free(clientssl);
    serverssl = clientssl = NULL;
    if (tst == 3) {
        testresult = 1;
        goto end;
    }
    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
                                      NULL, NULL))
            || !TEST_true(SSL_set_session(clientssl, sess))
            || !TEST_true(create_ssl_connection(serverssl, clientssl,
                                               SSL_ERROR_NONE)))
        goto end;
    if (tst == 0) {
        if (clntaddoldcb != 2
                || clntparseoldcb != 1
                || srvaddoldcb != 1
                || srvparseoldcb != 1)
            goto end;
    } else if (tst == 1 || tst == 2 || tst == 3) {
        if (clntaddnewcb != 2
                || clntparsenewcb != 2
                || srvaddnewcb != 2
                || srvparsenewcb != 2)
            goto end;
    } else {
        if (clntaddnewcb != 2
                || clntparsenewcb != 8
                || srvaddnewcb != 8
                || srvparsenewcb != 2)
            goto end;
    }
    testresult = 1;
end:
    SSL_SESSION_free(sess);
    SSL_free(serverssl);
    SSL_free(clientssl);
    SSL_CTX_free(sctx2);
    SSL_CTX_free(sctx);
    SSL_CTX_free(cctx);
    return testresult;
}
['static int test_custom_exts(int tst)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    static int server = 1;\n    static int client = 0;\n    SSL_SESSION *sess = NULL;\n    unsigned int context;\n#if defined(OPENSSL_NO_TLS1_2) && !defined(OPENSSL_NO_TLS1_3)\n    if (tst < 3)\n        return 1;\n#endif\n    clntaddoldcb = clntparseoldcb = srvaddoldcb = srvparseoldcb = 0;\n    clntaddnewcb = clntparsenewcb = srvaddnewcb = srvparsenewcb = 0;\n    snicb = 0;\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),\n                                       TLS1_VERSION, 0,\n                                       &sctx, &cctx, cert, privkey)))\n        goto end;\n    if (tst == 2\n            && !TEST_true(create_ssl_ctx_pair(TLS_server_method(), NULL,\n                                              TLS1_VERSION, 0,\n                                              &sctx2, NULL, cert, privkey)))\n        goto end;\n    if (tst < 3) {\n        SSL_CTX_set_options(cctx, SSL_OP_NO_TLSv1_3);\n        SSL_CTX_set_options(sctx, SSL_OP_NO_TLSv1_3);\n        if (sctx2 != NULL)\n            SSL_CTX_set_options(sctx2, SSL_OP_NO_TLSv1_3);\n    }\n    if (tst == 4) {\n        context = SSL_EXT_CLIENT_HELLO\n                  | SSL_EXT_TLS1_2_SERVER_HELLO\n                  | SSL_EXT_TLS1_3_SERVER_HELLO\n                  | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS\n                  | SSL_EXT_TLS1_3_CERTIFICATE\n                  | SSL_EXT_TLS1_3_NEW_SESSION_TICKET;\n    } else {\n        context = SSL_EXT_CLIENT_HELLO\n                  | SSL_EXT_TLS1_2_SERVER_HELLO\n                  | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS;\n    }\n    if (tst == 0) {\n        if (!TEST_true(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,\n                                                     old_add_cb, old_free_cb,\n                                                     &client, old_parse_cb,\n                                                     &client)))\n            goto end;\n    } else {\n        if (!TEST_true(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1, context,\n                                              new_add_cb, new_free_cb,\n                                              &client, new_parse_cb, &client)))\n            goto end;\n    }\n    if (!TEST_false(SSL_CTX_add_client_custom_ext(cctx, TEST_EXT_TYPE1,\n                                                  old_add_cb, old_free_cb,\n                                                  &client, old_parse_cb,\n                                                  &client))\n            || !TEST_false(SSL_CTX_add_custom_ext(cctx, TEST_EXT_TYPE1,\n                                                  context, new_add_cb,\n                                                  new_free_cb, &client,\n                                                  new_parse_cb, &client)))\n        goto end;\n    if (tst == 0) {\n        if (!TEST_true(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,\n                                                     old_add_cb, old_free_cb,\n                                                     &server, old_parse_cb,\n                                                     &server)))\n            goto end;\n    } else {\n        if (!TEST_true(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1, context,\n                                              new_add_cb, new_free_cb,\n                                              &server, new_parse_cb, &server)))\n            goto end;\n        if (sctx2 != NULL\n                && !TEST_true(SSL_CTX_add_custom_ext(sctx2, TEST_EXT_TYPE1,\n                                                     context, new_add_cb,\n                                                     new_free_cb, &server,\n                                                     new_parse_cb, &server)))\n            goto end;\n    }\n    if (!TEST_false(SSL_CTX_add_server_custom_ext(sctx, TEST_EXT_TYPE1,\n                                                  old_add_cb, old_free_cb,\n                                                  &server, old_parse_cb,\n                                                  &server))\n            || !TEST_false(SSL_CTX_add_custom_ext(sctx, TEST_EXT_TYPE1,\n                                                  context, new_add_cb,\n                                                  new_free_cb, &server,\n                                                  new_parse_cb, &server)))\n        goto end;\n    if (tst == 2) {\n        if (!TEST_true(SSL_CTX_set_tlsext_servername_callback(sctx, sni_cb))\n                || !TEST_true(SSL_CTX_set_tlsext_servername_arg(sctx, sctx2)))\n            goto end;\n    }\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,\n                                      &clientssl, NULL, NULL))\n            || !TEST_true(create_ssl_connection(serverssl, clientssl,\n                                                SSL_ERROR_NONE)))\n        goto end;\n    if (tst == 0) {\n        if (clntaddoldcb != 1\n                || clntparseoldcb != 1\n                || srvaddoldcb != 1\n                || srvparseoldcb != 1)\n            goto end;\n    } else if (tst == 1 || tst == 2 || tst == 3) {\n        if (clntaddnewcb != 1\n                || clntparsenewcb != 1\n                || srvaddnewcb != 1\n                || srvparsenewcb != 1\n                || (tst != 2 && snicb != 0)\n                || (tst == 2 && snicb != 1))\n            goto end;\n    } else {\n        if (clntaddnewcb != 1\n                || clntparsenewcb != 5\n                || srvaddnewcb != 5\n                || srvparsenewcb != 1)\n            goto end;\n    }\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 (tst == 3) {\n        testresult = 1;\n        goto end;\n    }\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,\n                                      NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl, sess))\n            || !TEST_true(create_ssl_connection(serverssl, clientssl,\n                                               SSL_ERROR_NONE)))\n        goto end;\n    if (tst == 0) {\n        if (clntaddoldcb != 2\n                || clntparseoldcb != 1\n                || srvaddoldcb != 1\n                || srvparseoldcb != 1)\n            goto end;\n    } else if (tst == 1 || tst == 2 || tst == 3) {\n        if (clntaddnewcb != 2\n                || clntparsenewcb != 2\n                || srvaddnewcb != 2\n                || srvparsenewcb != 2)\n            goto end;\n    } else {\n        if (clntaddnewcb != 2\n                || clntparsenewcb != 8\n                || srvaddnewcb != 8\n                || srvparsenewcb != 2)\n            goto end;\n    }\n    testresult = 1;\nend:\n    SSL_SESSION_free(sess);\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    SSL_CTX_free(sctx2);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,\n                        TLS_server_method,\n                        ossl_statem_accept,\n                        ssl_undefined_function, TLSv1_2_enc_data)', 'IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,\n                        TLS_client_method,\n                        ssl_undefined_function,\n                        ossl_statem_connect, TLSv1_2_enc_data)', 'int test_true(const char *file, int line, const char *s, int b)\n{\n    if (b)\n        return 1;\n    test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");\n    return 0;\n}', 'void SSL_SESSION_free(SSL_SESSION *ss)\n{\n    int i;\n    if (ss == NULL)\n        return;\n    CRYPTO_DOWN_REF(&ss->references, &i, ss->lock);\n    REF_PRINT_COUNT("SSL_SESSION", ss);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);\n    OPENSSL_cleanse(ss->master_key, sizeof(ss->master_key));\n    OPENSSL_cleanse(ss->session_id, sizeof(ss->session_id));\n    X509_free(ss->peer);\n    sk_X509_pop_free(ss->peer_chain, X509_free);\n    OPENSSL_free(ss->ext.hostname);\n    OPENSSL_free(ss->ext.tick);\n#ifndef OPENSSL_NO_PSK\n    OPENSSL_free(ss->psk_identity_hint);\n    OPENSSL_free(ss->psk_identity);\n#endif\n#ifndef OPENSSL_NO_SRP\n    OPENSSL_free(ss->srp_username);\n#endif\n    OPENSSL_free(ss->ext.alpn_selected);\n    OPENSSL_free(ss->ticket_appdata);\n    CRYPTO_THREAD_lock_free(ss->lock);\n    OPENSSL_clear_free(ss, sizeof(*ss));\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_NAME_pop_free(a->client_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}', 'static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)\n{\n    *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;\n    if (*ret == 0)\n        atomic_thread_fence(memory_order_acquire);\n    return 1;\n}']