test/handshake_helper.c:127: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 108 could be null and is dereferenced at line 127, column 9.
Showing all 49 steps of the trace


test/handshake_helper.c:105:1: start of procedure select_server_ctx()
103.    * An empty SNI extension also returns SSL_TSLEXT_ERR_NOACK.
104.    */
105. > static int select_server_ctx(SSL *s, void *arg, int ignore)
106.   {
107.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);

test/handshake_helper.c:107:5: 
105.   static int select_server_ctx(SSL *s, void *arg, int ignore)
106.   {
107. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
108.       HANDSHAKE_EX_DATA *ex_data =
109.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));

ssl/ssl_lib.c:2515:1: start of procedure SSL_get_servername()
  2513.    */
  2514.   
  2515. > const char *SSL_get_servername(const SSL *s, const int type)
  2516.   {
  2517.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2517:9: Taking false branch
  2515.   const char *SSL_get_servername(const SSL *s, const int type)
  2516.   {
  2517.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2518.           return NULL;
  2519.   

ssl/ssl_lib.c:2520:12: Condition is true
  2518.           return NULL;
  2519.   
  2520.       return s->session && !s->ext.hostname ?
                     ^
  2521.           s->session->ext.hostname : s->ext.hostname;
  2522.   }

ssl/ssl_lib.c:2520:27: Condition is true
  2518.           return NULL;
  2519.   
  2520.       return s->session && !s->ext.hostname ?
                                    ^
  2521.           s->session->ext.hostname : s->ext.hostname;
  2522.   }

ssl/ssl_lib.c:2520:12: 
  2518.           return NULL;
  2519.   
  2520. >     return s->session && !s->ext.hostname ?
  2521.           s->session->ext.hostname : s->ext.hostname;
  2522.   }

ssl/ssl_lib.c:2520:5: 
  2518.           return NULL;
  2519.   
  2520. >     return s->session && !s->ext.hostname ?
  2521.           s->session->ext.hostname : s->ext.hostname;
  2522.   }

ssl/ssl_lib.c:2522:1: return from a call to SSL_get_servername
  2520.       return s->session && !s->ext.hostname ?
  2521.           s->session->ext.hostname : s->ext.hostname;
  2522. > }
  2523.   
  2524.   int SSL_get_servername_type(const SSL *s)

test/handshake_helper.c:108:5: 
106.   {
107.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
108. >     HANDSHAKE_EX_DATA *ex_data =
109.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
110.   

ssl/ssl_lib.c:3926:1: start of procedure SSL_get_ex_data()
  3924.   }
  3925.   
  3926. > void *SSL_get_ex_data(const SSL *s, int idx)
  3927.   {
  3928.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:3928:5: 
  3926.   void *SSL_get_ex_data(const SSL *s, int idx)
  3927.   {
  3928. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  3929.   }
  3930.   

crypto/ex_data.c:393:1: start of procedure CRYPTO_get_ex_data()
    391.    * particular index in the class used by this variable
    392.    */
    393. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:395:9: Taking true branch
    393.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    396.           return NULL;
    397.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:396:9: 
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    396. >         return NULL;
    397.       return sk_void_value(ad->sk, idx);
    398.   }

crypto/ex_data.c:398:1: return from a call to CRYPTO_get_ex_data
    396.           return NULL;
    397.       return sk_void_value(ad->sk, idx);
    398. > }

ssl/ssl_lib.c:3929:1: return from a call to SSL_get_ex_data
  3927.   {
  3928.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  3929. > }
  3930.   
  3931.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:111:9: Taking false branch
109.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
110.   
111.       if (servername == NULL) {
               ^
112.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
113.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:116:9: Taking true branch
114.       }
115.   
116.       if (strcmp(servername, "server2") == 0) {
               ^
117.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
118.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:117:9: 
115.   
116.       if (strcmp(servername, "server2") == 0) {
117. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
118.           SSL_set_SSL_CTX(s, new_ctx);
119.           /*

test/handshake_helper.c:118:9: 
116.       if (strcmp(servername, "server2") == 0) {
117.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
118. >         SSL_set_SSL_CTX(s, new_ctx);
119.           /*
120.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3763:1: start of procedure SSL_set_SSL_CTX()
  3761.   }
  3762.   
  3763. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3764.   {
  3765.       CERT *new_cert;

ssl/ssl_lib.c:3766:9: Taking false branch
  3764.   {
  3765.       CERT *new_cert;
  3766.       if (ssl->ctx == ctx)
                  ^
  3767.           return ssl->ctx;
  3768.       if (ctx == NULL)

ssl/ssl_lib.c:3768:9: Taking false branch
  3766.       if (ssl->ctx == ctx)
  3767.           return ssl->ctx;
  3768.       if (ctx == NULL)
                  ^
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3770:5: Skipping ssl_cert_dup(): empty list of specs
  3768.       if (ctx == NULL)
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3771.       if (new_cert == NULL) {
  3772.           return NULL;

ssl/ssl_lib.c:3771:9: Taking false branch
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);
  3771.       if (new_cert == NULL) {
                  ^
  3772.           return NULL;
  3773.       }

ssl/ssl_lib.c:3775:10: Taking false branch
  3773.       }
  3774.   
  3775.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3776.           ssl_cert_free(new_cert);
  3777.           return NULL;

ssl/ssl_lib.c:3780:5: 
  3778.       }
  3779.   
  3780. >     ssl_cert_free(ssl->cert);
  3781.       ssl->cert = new_cert;
  3782.   

ssl/ssl_cert.c:224:1: start of procedure ssl_cert_free()
    222.   }
    223.   
    224. > void ssl_cert_free(CERT *c)
    225.   {
    226.       int i;

ssl/ssl_cert.c:228:9: Taking true branch
    226.       int i;
    227.   
    228.       if (c == NULL)
                   ^
    229.           return;
    230.   

ssl/ssl_cert.c:229:9: 
    227.   
    228.       if (c == NULL)
    229. >         return;
    230.   
    231.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

ssl/ssl_cert.c:254:1: return from a call to ssl_cert_free
    252.       CRYPTO_THREAD_lock_free(c->lock);
    253.       OPENSSL_free(c);
    254. > }
    255.   
    256.   int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain)

ssl/ssl_lib.c:3781:5: 
  3779.   
  3780.       ssl_cert_free(ssl->cert);
  3781. >     ssl->cert = new_cert;
  3782.   
  3783.       /*

ssl/ssl_lib.c:3787:10: Condition is false
  3785.        * so setter APIs must prevent invalid lengths from entering the system.
  3786.        */
  3787.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3788.           return NULL;
  3789.   

ssl/ssl_lib.c:3787:10: Taking true branch
  3785.        * so setter APIs must prevent invalid lengths from entering the system.
  3786.        */
  3787.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3788.           return NULL;
  3789.   

ssl/ssl_lib.c:3788:9: 
  3786.        */
  3787.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3788. >         return NULL;
  3789.   
  3790.       /*

ssl/ssl_lib.c:3808:1: return from a call to SSL_set_SSL_CTX
  3806.   
  3807.       return ssl->ctx;
  3808. > }
  3809.   
  3810.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:124:9: 
122.            * contexts differ/conflict
123.            */
124. >         SSL_clear_options(s, 0xFFFFFFFFL);
125.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
126.   

ssl/ssl_lib.c:4344:1: start of procedure SSL_clear_options()
  4342.   }
  4343.   
  4344. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4345.   {
  4346.       return s->options &= ~op;

ssl/ssl_lib.c:4346:5: 
  4344.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4345.   {
  4346. >     return s->options &= ~op;
  4347.   }
  4348.   

ssl/ssl_lib.c:4347:1: return from a call to SSL_clear_options
  4345.   {
  4346.       return s->options &= ~op;
  4347. > }
  4348.   
  4349.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:125:9: 
123.            */
124.           SSL_clear_options(s, 0xFFFFFFFFL);
125. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
126.   
127.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4319:1: start of procedure SSL_CTX_get_options()
  4317.    * control interface.
  4318.    */
  4319. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4320.   {
  4321.       return ctx->options;

ssl/ssl_lib.c:4321:5: 
  4319.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4320.   {
  4321. >     return ctx->options;
  4322.   }
  4323.   

ssl/ssl_lib.c:4322:1: return from a call to SSL_CTX_get_options
  4320.   {
  4321.       return ctx->options;
  4322. > }
  4323.   
  4324.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4334:1: start of procedure SSL_set_options()
  4332.   }
  4333.   
  4334. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4335.   {
  4336.       return s->options |= op;

ssl/ssl_lib.c:4336:5: 
  4334.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4335.   {
  4336. >     return s->options |= op;
  4337.   }
  4338.   

ssl/ssl_lib.c:4337:1: return from a call to SSL_set_options
  4335.   {
  4336.       return s->options |= op;
  4337. > }
  4338.   
  4339.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

test/handshake_helper.c:127:9: 
125.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
126.   
127. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
128.           return SSL_TLSEXT_ERR_OK;
129.       } else if (strcmp(servername, "server1") == 0) {
