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:2763:1: start of procedure SSL_get_servername()
  2761.    */
  2762.   
  2763. > const char *SSL_get_servername(const SSL *s, const int type)
  2764.   {
  2765.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2765:9: Taking false branch
  2763.   const char *SSL_get_servername(const SSL *s, const int type)
  2764.   {
  2765.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2766.           return NULL;
  2767.   

ssl/ssl_lib.c:2774:9: Taking true branch
  2772.        * might error out if there is not a SNI value available.
  2773.        */
  2774.       if (s->hit)
                  ^
  2775.           return s->session->ext.hostname;
  2776.       return s->ext.hostname;

ssl/ssl_lib.c:2775:9: 
  2773.        */
  2774.       if (s->hit)
  2775. >         return s->session->ext.hostname;
  2776.       return s->ext.hostname;
  2777.   }

ssl/ssl_lib.c:2777:1: return from a call to SSL_get_servername
  2775.           return s->session->ext.hostname;
  2776.       return s->ext.hostname;
  2777. > }
  2778.   
  2779.   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:4291:1: start of procedure SSL_get_ex_data()
  4289.   }
  4290.   
  4291. > void *SSL_get_ex_data(const SSL *s, int idx)
  4292.   {
  4293.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4293:5: 
  4291.   void *SSL_get_ex_data(const SSL *s, int idx)
  4292.   {
  4293. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4294.   }
  4295.   

crypto/ex_data.c:458:1: start of procedure CRYPTO_get_ex_data()
    456.    * particular index in the class used by this variable
    457.    */
    458. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    459.   {
    460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:460:9: Taking true branch
    458.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    459.   {
    460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    461.           return NULL;
    462.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:461:9: 
    459.   {
    460.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    461. >         return NULL;
    462.       return sk_void_value(ad->sk, idx);
    463.   }

crypto/ex_data.c:463:1: return from a call to CRYPTO_get_ex_data
    461.           return NULL;
    462.       return sk_void_value(ad->sk, idx);
    463. > }
    464.   
    465.   OPENSSL_CTX *crypto_ex_data_get_openssl_ctx(const CRYPTO_EX_DATA *ad)

ssl/ssl_lib.c:4294:1: return from a call to SSL_get_ex_data
  4292.   {
  4293.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4294. > }
  4295.   
  4296.   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:4128:1: start of procedure SSL_set_SSL_CTX()
  4126.   }
  4127.   
  4128. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  4129.   {
  4130.       CERT *new_cert;

ssl/ssl_lib.c:4131:9: Taking false branch
  4129.   {
  4130.       CERT *new_cert;
  4131.       if (ssl->ctx == ctx)
                  ^
  4132.           return ssl->ctx;
  4133.       if (ctx == NULL)

ssl/ssl_lib.c:4133:9: Taking false branch
  4131.       if (ssl->ctx == ctx)
  4132.           return ssl->ctx;
  4133.       if (ctx == NULL)
                  ^
  4134.           ctx = ssl->session_ctx;
  4135.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:4135:5: Skipping ssl_cert_dup(): empty list of specs
  4133.       if (ctx == NULL)
  4134.           ctx = ssl->session_ctx;
  4135.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  4136.       if (new_cert == NULL) {
  4137.           return NULL;

ssl/ssl_lib.c:4136:9: Taking false branch
  4134.           ctx = ssl->session_ctx;
  4135.       new_cert = ssl_cert_dup(ctx->cert);
  4136.       if (new_cert == NULL) {
                  ^
  4137.           return NULL;
  4138.       }

ssl/ssl_lib.c:4140:10: Taking false branch
  4138.       }
  4139.   
  4140.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  4141.           ssl_cert_free(new_cert);
  4142.           return NULL;

ssl/ssl_lib.c:4145:5: 
  4143.       }
  4144.   
  4145. >     ssl_cert_free(ssl->cert);
  4146.       ssl->cert = new_cert;
  4147.   

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

ssl/ssl_cert.c:226:9: Taking true branch
    224.       int i;
    225.   
    226.       if (c == NULL)
                   ^
    227.           return;
    228.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

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

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

ssl/ssl_lib.c:4146:5: 
  4144.   
  4145.       ssl_cert_free(ssl->cert);
  4146. >     ssl->cert = new_cert;
  4147.   
  4148.       /*

ssl/ssl_lib.c:4152:10: Condition is false
  4150.        * so setter APIs must prevent invalid lengths from entering the system.
  4151.        */
  4152.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4153.           return NULL;
  4154.   

ssl/ssl_lib.c:4152:10: Taking true branch
  4150.        * so setter APIs must prevent invalid lengths from entering the system.
  4151.        */
  4152.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4153.           return NULL;
  4154.   

ssl/ssl_lib.c:4153:9: 
  4151.        */
  4152.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  4153. >         return NULL;
  4154.   
  4155.       /*

ssl/ssl_lib.c:4173:1: return from a call to SSL_set_SSL_CTX
  4171.   
  4172.       return ssl->ctx;
  4173. > }
  4174.   
  4175.   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:4739:1: start of procedure SSL_clear_options()
  4737.   }
  4738.   
  4739. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4740.   {
  4741.       return s->options &= ~op;

ssl/ssl_lib.c:4741:5: 
  4739.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4740.   {
  4741. >     return s->options &= ~op;
  4742.   }
  4743.   

ssl/ssl_lib.c:4742:1: return from a call to SSL_clear_options
  4740.   {
  4741.       return s->options &= ~op;
  4742. > }
  4743.   
  4744.   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:4714:1: start of procedure SSL_CTX_get_options()
  4712.    * control interface.
  4713.    */
  4714. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4715.   {
  4716.       return ctx->options;

ssl/ssl_lib.c:4716:5: 
  4714.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4715.   {
  4716. >     return ctx->options;
  4717.   }
  4718.   

ssl/ssl_lib.c:4717:1: return from a call to SSL_CTX_get_options
  4715.   {
  4716.       return ctx->options;
  4717. > }
  4718.   
  4719.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4729:1: start of procedure SSL_set_options()
  4727.   }
  4728.   
  4729. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4730.   {
  4731.       return s->options |= op;

ssl/ssl_lib.c:4731:5: 
  4729.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4730.   {
  4731. >     return s->options |= op;
  4732.   }
  4733.   

ssl/ssl_lib.c:4732:1: return from a call to SSL_set_options
  4730.   {
  4731.       return s->options |= op;
  4732. > }
  4733.   
  4734.   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) {
