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


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

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

ssl/ssl_lib.c:2481:1: start of procedure SSL_get_servername()
  2479.    */
  2480.   
  2481. > const char *SSL_get_servername(const SSL *s, const int type)
  2482.   {
  2483.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2483:9: Taking false branch
  2481.   const char *SSL_get_servername(const SSL *s, const int type)
  2482.   {
  2483.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2484.           return NULL;
  2485.   

ssl/ssl_lib.c:2486:12: Condition is true
  2484.           return NULL;
  2485.   
  2486.       return s->session && !s->ext.hostname ?
                     ^
  2487.           s->session->ext.hostname : s->ext.hostname;
  2488.   }

ssl/ssl_lib.c:2486:27: Condition is true
  2484.           return NULL;
  2485.   
  2486.       return s->session && !s->ext.hostname ?
                                    ^
  2487.           s->session->ext.hostname : s->ext.hostname;
  2488.   }

ssl/ssl_lib.c:2486:12: 
  2484.           return NULL;
  2485.   
  2486. >     return s->session && !s->ext.hostname ?
  2487.           s->session->ext.hostname : s->ext.hostname;
  2488.   }

ssl/ssl_lib.c:2486:5: 
  2484.           return NULL;
  2485.   
  2486. >     return s->session && !s->ext.hostname ?
  2487.           s->session->ext.hostname : s->ext.hostname;
  2488.   }

ssl/ssl_lib.c:2488:1: return from a call to SSL_get_servername
  2486.       return s->session && !s->ext.hostname ?
  2487.           s->session->ext.hostname : s->ext.hostname;
  2488. > }
  2489.   
  2490.   int SSL_get_servername_type(const SSL *s)

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

ssl/ssl_lib.c:3883:1: start of procedure SSL_get_ex_data()
  3881.   }
  3882.   
  3883. > void *SSL_get_ex_data(const SSL *s, int idx)
  3884.   {
  3885.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3885:5: 
  3883.   void *SSL_get_ex_data(const SSL *s, int idx)
  3884.   {
  3885. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3886.   }
  3887.   

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:3886:1: return from a call to SSL_get_ex_data
  3884.   {
  3885.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3886. > }
  3887.   
  3888.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

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

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

ssl/ssl_lib.c:3720:1: start of procedure SSL_set_SSL_CTX()
  3718.   }
  3719.   
  3720. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3721.   {
  3722.       CERT *new_cert;

ssl/ssl_lib.c:3723:9: Taking false branch
  3721.   {
  3722.       CERT *new_cert;
  3723.       if (ssl->ctx == ctx)
                  ^
  3724.           return ssl->ctx;
  3725.       if (ctx == NULL)

ssl/ssl_lib.c:3725:9: Taking false branch
  3723.       if (ssl->ctx == ctx)
  3724.           return ssl->ctx;
  3725.       if (ctx == NULL)
                  ^
  3726.           ctx = ssl->session_ctx;
  3727.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3727:5: Skipping ssl_cert_dup(): empty list of specs
  3725.       if (ctx == NULL)
  3726.           ctx = ssl->session_ctx;
  3727.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3728.       if (new_cert == NULL) {
  3729.           return NULL;

ssl/ssl_lib.c:3728:9: Taking false branch
  3726.           ctx = ssl->session_ctx;
  3727.       new_cert = ssl_cert_dup(ctx->cert);
  3728.       if (new_cert == NULL) {
                  ^
  3729.           return NULL;
  3730.       }

ssl/ssl_lib.c:3732:10: Taking false branch
  3730.       }
  3731.   
  3732.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3733.           ssl_cert_free(new_cert);
  3734.           return NULL;

ssl/ssl_lib.c:3737:5: 
  3735.       }
  3736.   
  3737. >     ssl_cert_free(ssl->cert);
  3738.       ssl->cert = new_cert;
  3739.   

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

ssl/ssl_cert.c:231:9: Taking true branch
    229.       int i;
    230.   
    231.       if (c == NULL)
                   ^
    232.           return;
    233.   

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

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

ssl/ssl_lib.c:3738:5: 
  3736.   
  3737.       ssl_cert_free(ssl->cert);
  3738. >     ssl->cert = new_cert;
  3739.   
  3740.       /*

ssl/ssl_lib.c:3744:10: Condition is false
  3742.        * so setter APIs must prevent invalid lengths from entering the system.
  3743.        */
  3744.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3745.           return NULL;
  3746.   

ssl/ssl_lib.c:3744:10: Taking true branch
  3742.        * so setter APIs must prevent invalid lengths from entering the system.
  3743.        */
  3744.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3745.           return NULL;
  3746.   

ssl/ssl_lib.c:3745:9: 
  3743.        */
  3744.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3745. >         return NULL;
  3746.   
  3747.       /*

ssl/ssl_lib.c:3765:1: return from a call to SSL_set_SSL_CTX
  3763.   
  3764.       return ssl->ctx;
  3765. > }
  3766.   
  3767.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

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

ssl/ssl_lib.c:4301:1: start of procedure SSL_clear_options()
  4299.   }
  4300.   
  4301. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4302.   {
  4303.       return s->options &= ~op;

ssl/ssl_lib.c:4303:5: 
  4301.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4302.   {
  4303. >     return s->options &= ~op;
  4304.   }
  4305.   

ssl/ssl_lib.c:4304:1: return from a call to SSL_clear_options
  4302.   {
  4303.       return s->options &= ~op;
  4304. > }
  4305.   
  4306.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

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

ssl/ssl_lib.c:4276:1: start of procedure SSL_CTX_get_options()
  4274.    * control interface.
  4275.    */
  4276. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4277.   {
  4278.       return ctx->options;

ssl/ssl_lib.c:4278:5: 
  4276.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4277.   {
  4278. >     return ctx->options;
  4279.   }
  4280.   

ssl/ssl_lib.c:4279:1: return from a call to SSL_CTX_get_options
  4277.   {
  4278.       return ctx->options;
  4279. > }
  4280.   
  4281.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4291:1: start of procedure SSL_set_options()
  4289.   }
  4290.   
  4291. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4292.   {
  4293.       return s->options |= op;

ssl/ssl_lib.c:4293:5: 
  4291.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4292.   {
  4293. >     return s->options |= op;
  4294.   }
  4295.   

ssl/ssl_lib.c:4294:1: return from a call to SSL_set_options
  4292.   {
  4293.       return s->options |= op;
  4294. > }
  4295.   
  4296.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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