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


test/sslapitest.c:4783:1: start of procedure test_export_key_mat()
4781.   #define SMALL_LABEL_LEN 10
4782.   #define LONG_LABEL_LEN  249
4783. > static int test_export_key_mat(int tst)
4784.   {
4785.       int testresult = 0;

test/sslapitest.c:4785:5: 
4783.   static int test_export_key_mat(int tst)
4784.   {
4785. >     int testresult = 0;
4786.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4787.       SSL *clientssl = NULL, *serverssl = NULL;

test/sslapitest.c:4786:5: 
4784.   {
4785.       int testresult = 0;
4786. >     SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4787.       SSL *clientssl = NULL, *serverssl = NULL;
4788.       const char label[LONG_LABEL_LEN + 1] = "test label";

test/sslapitest.c:4787:5: 
4785.       int testresult = 0;
4786.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4787. >     SSL *clientssl = NULL, *serverssl = NULL;
4788.       const char label[LONG_LABEL_LEN + 1] = "test label";
4789.       const unsigned char context[] = "context";

test/sslapitest.c:4788:5: 
4786.       SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
4787.       SSL *clientssl = NULL, *serverssl = NULL;
4788. >     const char label[LONG_LABEL_LEN + 1] = "test label";
4789.       const unsigned char context[] = "context";
4790.       const unsigned char *emptycontext = NULL;

test/sslapitest.c:4789:5: 
4787.       SSL *clientssl = NULL, *serverssl = NULL;
4788.       const char label[LONG_LABEL_LEN + 1] = "test label";
4789. >     const unsigned char context[] = "context";
4790.       const unsigned char *emptycontext = NULL;
4791.       unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80];

test/sslapitest.c:4790:5: 
4788.       const char label[LONG_LABEL_LEN + 1] = "test label";
4789.       const unsigned char context[] = "context";
4790. >     const unsigned char *emptycontext = NULL;
4791.       unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80];
4792.       unsigned char skeymat1[80], skeymat2[80], skeymat3[80];

test/sslapitest.c:4794:5: 
4792.       unsigned char skeymat1[80], skeymat2[80], skeymat3[80];
4793.       size_t labellen;
4794. >     const int protocols[] = {
4795.           TLS1_VERSION,
4796.           TLS1_1_VERSION,

test/sslapitest.c:4819:10: 
4817.           return 1;
4818.   #endif
4819. >     if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
4820.                                          TLS1_VERSION, 0,
4821.                                          &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:4819:10: Condition is true
4817.           return 1;
4818.   #endif
4819.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4820.                                          TLS1_VERSION, 0,
4821.                                          &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:4819:10: Taking false branch
4817.           return 1;
4818.   #endif
4819.       if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                 ^
4820.                                          TLS1_VERSION, 0,
4821.                                          &sctx, &cctx, cert, privkey)))

test/sslapitest.c:4824:5: Condition is true
4822.           goto end;
4823.   
4824.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
            ^
4825.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
4826.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);

test/sslapitest.c:4824:5: Condition is true
4822.           goto end;
4823.   
4824.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
            ^
4825.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
4826.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);

test/sslapitest.c:4825:5: Skipping SSL_CTX_ctrl(): empty list of specs
4823.   
4824.       OPENSSL_assert(tst >= 0 && (size_t)tst < OSSL_NELEM(protocols));
4825.       SSL_CTX_set_max_proto_version(cctx, protocols[tst]);
            ^
4826.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4827.   

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

test/sslapitest.c:4828:10: Condition is true
4826.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4827.   
4828.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
                 ^
4829.                                         NULL))
4830.               || !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:4828:10: Taking false branch
4826.       SSL_CTX_set_min_proto_version(cctx, protocols[tst]);
4827.   
4828.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
                 ^
4829.                                         NULL))
4830.               || !TEST_true(create_ssl_connection(serverssl, clientssl,

test/sslapitest.c:4830:17: 
4828.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4829.                                         NULL))
4830. >             || !TEST_true(create_ssl_connection(serverssl, clientssl,
4831.                                                   SSL_ERROR_NONE)))
4832.           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:4830:17: Condition is false
4828.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4829.                                         NULL))
4830.               || !TEST_true(create_ssl_connection(serverssl, clientssl,
                        ^
4831.                                                   SSL_ERROR_NONE)))
4832.           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:4830:17: Taking true branch
4828.       if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL,
4829.                                         NULL))
4830.               || !TEST_true(create_ssl_connection(serverssl, clientssl,
                        ^
4831.                                                   SSL_ERROR_NONE)))
4832.           goto end;

test/sslapitest.c:4916:2: 
4914.       testresult = 1;
4915.   
4916. >  end:
4917.       SSL_free(serverssl);
4918.       SSL_free(clientssl);

test/sslapitest.c:4917:5: Skipping SSL_free(): empty list of specs
4915.   
4916.    end:
4917.       SSL_free(serverssl);
            ^
4918.       SSL_free(clientssl);
4919.       SSL_CTX_free(sctx2);

test/sslapitest.c:4918:5: Skipping SSL_free(): empty list of specs
4916.    end:
4917.       SSL_free(serverssl);
4918.       SSL_free(clientssl);
            ^
4919.       SSL_CTX_free(sctx2);
4920.       SSL_CTX_free(sctx);

test/sslapitest.c:4919:5: 
4917.       SSL_free(serverssl);
4918.       SSL_free(clientssl);
4919. >     SSL_CTX_free(sctx2);
4920.       SSL_CTX_free(sctx);
4921.       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)
