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


test/handshake_helper.c:114:1: start of procedure select_server_ctx()
112.    * An empty SNI extension also returns SSL_TSLEXT_ERR_NOACK.
113.    */
114. > static int select_server_ctx(SSL *s, void *arg, int ignore)
115.   {
116.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);

test/handshake_helper.c:116:5: 
114.   static int select_server_ctx(SSL *s, void *arg, int ignore)
115.   {
116. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
117.       HANDSHAKE_EX_DATA *ex_data =
118.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));

ssl/ssl_lib.c:2673:1: start of procedure SSL_get_servername()
  2671.    */
  2672.   
  2673. > const char *SSL_get_servername(const SSL *s, const int type)
  2674.   {
  2675.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2675:9: Taking false branch
  2673.   const char *SSL_get_servername(const SSL *s, const int type)
  2674.   {
  2675.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2676.           return NULL;
  2677.   

ssl/ssl_lib.c:2684:9: Taking true branch
  2682.        * might error out if there is not a SNI value available.
  2683.        */
  2684.       if (s->hit)
                  ^
  2685.           return s->session->ext.hostname;
  2686.       return s->ext.hostname;

ssl/ssl_lib.c:2685:9: 
  2683.        */
  2684.       if (s->hit)
  2685. >         return s->session->ext.hostname;
  2686.       return s->ext.hostname;
  2687.   }

ssl/ssl_lib.c:2687:1: return from a call to SSL_get_servername
  2685.           return s->session->ext.hostname;
  2686.       return s->ext.hostname;
  2687. > }
  2688.   
  2689.   int SSL_get_servername_type(const SSL *s)

test/handshake_helper.c:117:5: 
115.   {
116.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
117. >     HANDSHAKE_EX_DATA *ex_data =
118.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
119.   

ssl/ssl_lib.c:4205:1: start of procedure SSL_get_ex_data()
  4203.   }
  4204.   
  4205. > void *SSL_get_ex_data(const SSL *s, int idx)
  4206.   {
  4207.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4207:5: 
  4205.   void *SSL_get_ex_data(const SSL *s, int idx)
  4206.   {
  4207. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4208.   }
  4209.   

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

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

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

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

ssl/ssl_lib.c:4208:1: return from a call to SSL_get_ex_data
  4206.   {
  4207.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4208. > }
  4209.   
  4210.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:120:9: Taking false branch
118.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
119.   
120.       if (servername == NULL) {
               ^
121.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
122.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:125:9: Taking true branch
123.       }
124.   
125.       if (strcmp(servername, "server2") == 0) {
               ^
126.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
127.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:126:9: 
124.   
125.       if (strcmp(servername, "server2") == 0) {
126. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
127.           SSL_set_SSL_CTX(s, new_ctx);
128.           /*

test/handshake_helper.c:127:9: 
125.       if (strcmp(servername, "server2") == 0) {
126.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
127. >         SSL_set_SSL_CTX(s, new_ctx);
128.           /*
129.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:4042:1: start of procedure SSL_set_SSL_CTX()
  4040.   }
  4041.   
  4042. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  4043.   {
  4044.       CERT *new_cert;

ssl/ssl_lib.c:4045:9: Taking false branch
  4043.   {
  4044.       CERT *new_cert;
  4045.       if (ssl->ctx == ctx)
                  ^
  4046.           return ssl->ctx;
  4047.       if (ctx == NULL)

ssl/ssl_lib.c:4047:9: Taking false branch
  4045.       if (ssl->ctx == ctx)
  4046.           return ssl->ctx;
  4047.       if (ctx == NULL)
                  ^
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:4049:5: Skipping ssl_cert_dup(): empty list of specs
  4047.       if (ctx == NULL)
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  4050.       if (new_cert == NULL) {
  4051.           return NULL;

ssl/ssl_lib.c:4050:9: Taking false branch
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);
  4050.       if (new_cert == NULL) {
                  ^
  4051.           return NULL;
  4052.       }

ssl/ssl_lib.c:4054:10: Taking false branch
  4052.       }
  4053.   
  4054.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  4055.           ssl_cert_free(new_cert);
  4056.           return NULL;

ssl/ssl_lib.c:4059:5: 
  4057.       }
  4058.   
  4059. >     ssl_cert_free(ssl->cert);
  4060.       ssl->cert = new_cert;
  4061.   

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.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

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

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

ssl/ssl_lib.c:4060:5: 
  4058.   
  4059.       ssl_cert_free(ssl->cert);
  4060. >     ssl->cert = new_cert;
  4061.   
  4062.       /*

ssl/ssl_lib.c:4066:10: Condition is false
  4064.        * so setter APIs must prevent invalid lengths from entering the system.
  4065.        */
  4066.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4067.           return NULL;
  4068.   

ssl/ssl_lib.c:4066:10: Taking true branch
  4064.        * so setter APIs must prevent invalid lengths from entering the system.
  4065.        */
  4066.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4067.           return NULL;
  4068.   

ssl/ssl_lib.c:4067:9: 
  4065.        */
  4066.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  4067. >         return NULL;
  4068.   
  4069.       /*

ssl/ssl_lib.c:4087:1: return from a call to SSL_set_SSL_CTX
  4085.   
  4086.       return ssl->ctx;
  4087. > }
  4088.   
  4089.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:133:9: 
131.            * contexts differ/conflict
132.            */
133. >         SSL_clear_options(s, 0xFFFFFFFFL);
134.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
135.   

ssl/ssl_lib.c:4653:1: start of procedure SSL_clear_options()
  4651.   }
  4652.   
  4653. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4654.   {
  4655.       return s->options &= ~op;

ssl/ssl_lib.c:4655:5: 
  4653.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4654.   {
  4655. >     return s->options &= ~op;
  4656.   }
  4657.   

ssl/ssl_lib.c:4656:1: return from a call to SSL_clear_options
  4654.   {
  4655.       return s->options &= ~op;
  4656. > }
  4657.   
  4658.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:134:9: 
132.            */
133.           SSL_clear_options(s, 0xFFFFFFFFL);
134. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
135.   
136.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4628:1: start of procedure SSL_CTX_get_options()
  4626.    * control interface.
  4627.    */
  4628. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4629.   {
  4630.       return ctx->options;

ssl/ssl_lib.c:4630:5: 
  4628.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4629.   {
  4630. >     return ctx->options;
  4631.   }
  4632.   

ssl/ssl_lib.c:4631:1: return from a call to SSL_CTX_get_options
  4629.   {
  4630.       return ctx->options;
  4631. > }
  4632.   
  4633.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4643:1: start of procedure SSL_set_options()
  4641.   }
  4642.   
  4643. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4644.   {
  4645.       return s->options |= op;

ssl/ssl_lib.c:4645:5: 
  4643.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4644.   {
  4645. >     return s->options |= op;
  4646.   }
  4647.   

ssl/ssl_lib.c:4646:1: return from a call to SSL_set_options
  4644.   {
  4645.       return s->options |= op;
  4646. > }
  4647.   
  4648.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

test/handshake_helper.c:136:9: 
134.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
135.   
136. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
137.           return SSL_TLSEXT_ERR_OK;
138.       } else if (strcmp(servername, "server1") == 0) {
