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


test/sslapitest.c:4605:1: start of procedure test_export_key_mat()
4603.   #define SMALL_LABEL_LEN 10
4604.   #define LONG_LABEL_LEN  249
4605. > static int test_export_key_mat(int tst)
4606.   {
4607.       int testresult = 0;

test/sslapitest.c:4607:5: 
4605.   static int test_export_key_mat(int tst)
4606.   {
4607. >     int testresult = 0;
4608.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4609.       SSL *clientssl = NULL, *serverssl = NULL;

test/sslapitest.c:4608:5: 
4606.   {
4607.       int testresult = 0;
4608. >     SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4609.       SSL *clientssl = NULL, *serverssl = NULL;
4610.       const char label[LONG_LABEL_LEN + 1] = "test label";

test/sslapitest.c:4609:5: 
4607.       int testresult = 0;
4608.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4609. >     SSL *clientssl = NULL, *serverssl = NULL;
4610.       const char label[LONG_LABEL_LEN + 1] = "test label";
4611.       const unsigned char context[] = "context";

test/sslapitest.c:4610:5: 
4608.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4609.       SSL *clientssl = NULL, *serverssl = NULL;
4610. >     const char label[LONG_LABEL_LEN + 1] = "test label";
4611.       const unsigned char context[] = "context";
4612.       const unsigned char *emptycontext = NULL;

test/sslapitest.c:4611:5: 
4609.       SSL *clientssl = NULL, *serverssl = NULL;
4610.       const char label[LONG_LABEL_LEN + 1] = "test label";
4611. >     const unsigned char context[] = "context";
4612.       const unsigned char *emptycontext = NULL;
4613.       unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80];

test/sslapitest.c:4612:5: 
4610.       const char label[LONG_LABEL_LEN + 1] = "test label";
4611.       const unsigned char context[] = "context";
4612. >     const unsigned char *emptycontext = NULL;
4613.       unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80];
4614.       unsigned char skeymat1[80], skeymat2[80], skeymat3[80];

test/sslapitest.c:4616:5: 
4614.       unsigned char skeymat1[80], skeymat2[80], skeymat3[80];
4615.       size_t labellen;
4616. >     const int protocols[] = {
4617.           TLS1_VERSION,
4618.           TLS1_1_VERSION,

test/sslapitest.c:4641:10: 
4639.           return 1;
4640.   #endif
4641. >     if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
4642.                                          TLS1_VERSION, 0,
4643.                                          &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:4641:10: Condition is true
4639.           return 1;
4640.   #endif
4641.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4642.                                          TLS1_VERSION, 0,
4643.                                          &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 true 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:263:9: 
  261.   {
  262.       if (b)
  263. >         return 1;
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  265.       return 0;

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:4641:10: Taking false branch
4639.           return 1;
4640.   #endif
4641.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4642.                                          TLS1_VERSION, 0,
4643.                                          &sctx, &cctx, cert, privkey)))

test/sslapitest.c:4646:5: Condition is true
4644.           goto end;
4645.   
4646.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
            ^
4647.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);

test/sslapitest.c:4646:5: Condition is true
4644.           goto end;
4645.   
4646.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
            ^
4647.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);

test/sslapitest.c:4647:5: Skipping SSL_CTX_ctrl(): empty list of specs
4645.   
4646.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
4647.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
            ^
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4649.   

test/sslapitest.c:4648:5: Skipping SSL_CTX_ctrl(): empty list of specs
4646.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
4647.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
            ^
4649.   
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,

test/sslapitest.c:4650:10: Condition is true
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4649.   
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
                 ^
4651.                                         NULL))
4652.               || !TEST_true(create_ssl_connection(serverssl, clientssl,

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 true 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:263:9: 
  261.   {
  262.       if (b)
  263. >         return 1;
  264.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  265.       return 0;

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:4650:10: Taking false branch
4648.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4649.   
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
                 ^
4651.                                         NULL))
4652.               || !TEST_true(create_ssl_connection(serverssl, clientssl,

test/sslapitest.c:4652:17: 
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4651.                                         NULL))
4652. >             || !TEST_true(create_ssl_connection(serverssl, clientssl,
4653.                                                   SSL_ERROR_NONE)))
4654.           goto end;

test/ssltestlib.c:1027:1: start of procedure create_ssl_connection()
  1025.    * messages.
  1026.    */
  1027. > int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want)
  1028.   {
  1029.       int i;

test/ssltestlib.c:1033:10: Taking true branch
  1031.       size_t readbytes;
  1032.   
  1033.       if (!create_bare_ssl_connection(serverssl, clientssl, want, 1))
                   ^
  1034.           return 0;
  1035.   

test/ssltestlib.c:1034:9: 
  1032.   
  1033.       if (!create_bare_ssl_connection(serverssl, clientssl, want, 1))
  1034. >         return 0;
  1035.   
  1036.       /*

test/ssltestlib.c:1052:1: return from a call to create_ssl_connection
  1050.   
  1051.       return 1;
  1052. > }
  1053.   
  1054.   void shutdown_ssl_connection(SSL *serverssl, SSL *clientssl)

test/sslapitest.c:4652:17: Condition is false
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4651.                                         NULL))
4652.               || !TEST_true(create_ssl_connection(serverssl, clientssl,
                        ^
4653.                                                   SSL_ERROR_NONE)))
4654.           goto end;

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:4652:17: Taking true branch
4650.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4651.                                         NULL))
4652.               || !TEST_true(create_ssl_connection(serverssl, clientssl,
                        ^
4653.                                                   SSL_ERROR_NONE)))
4654.           goto end;

test/sslapitest.c:4738:2: 
4736.       testresult = 1;
4737.   
4738. >  end:
4739.       SSL_free(serverssl);
4740.       SSL_free(clientssl);

test/sslapitest.c:4739:5: Skipping SSL_free(): empty list of specs
4737.   
4738.    end:
4739.       SSL_free(serverssl);
            ^
4740.       SSL_free(clientssl);
4741.       SSL_CTX_free(sctx2);

test/sslapitest.c:4740:5: Skipping SSL_free(): empty list of specs
4738.    end:
4739.       SSL_free(serverssl);
4740.       SSL_free(clientssl);
            ^
4741.       SSL_CTX_free(sctx2);
4742.       SSL_CTX_free(sctx);

test/sslapitest.c:4741:5: 
4739.       SSL_free(serverssl);
4740.       SSL_free(clientssl);
4741. >     SSL_CTX_free(sctx2);
4742.       SSL_CTX_free(sctx);
4743.       SSL_CTX_free(cctx);

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

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

ssl/ssl_lib.c:3246:5: 
  3244.           return;
  3245.   
  3246. >     CRYPTO_DOWN_REF(&a->references, &i, a->lock);
  3247.       REF_PRINT_COUNT("SSL_CTX", a);
  3248.       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:3248:9: Taking true branch
  3246.       CRYPTO_DOWN_REF(&a->references, &i, a->lock);
  3247.       REF_PRINT_COUNT("SSL_CTX", a);
  3248.       if (i > 0)
                  ^
  3249.           return;
  3250.       REF_ASSERT_ISNT(i < 0);

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

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