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:2500:1: start of procedure SSL_get_servername()
  2498.    */
  2499.   
  2500. > const char *SSL_get_servername(const SSL *s, const int type)
  2501.   {
  2502.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2502:9: Taking false branch
  2500.   const char *SSL_get_servername(const SSL *s, const int type)
  2501.   {
  2502.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2503.           return NULL;
  2504.   

ssl/ssl_lib.c:2505:12: Condition is true
  2503.           return NULL;
  2504.   
  2505.       return s->session && !s->ext.hostname ?
                     ^
  2506.           s->session->ext.hostname : s->ext.hostname;
  2507.   }

ssl/ssl_lib.c:2505:27: Condition is true
  2503.           return NULL;
  2504.   
  2505.       return s->session && !s->ext.hostname ?
                                    ^
  2506.           s->session->ext.hostname : s->ext.hostname;
  2507.   }

ssl/ssl_lib.c:2505:12: 
  2503.           return NULL;
  2504.   
  2505. >     return s->session && !s->ext.hostname ?
  2506.           s->session->ext.hostname : s->ext.hostname;
  2507.   }

ssl/ssl_lib.c:2505:5: 
  2503.           return NULL;
  2504.   
  2505. >     return s->session && !s->ext.hostname ?
  2506.           s->session->ext.hostname : s->ext.hostname;
  2507.   }

ssl/ssl_lib.c:2507:1: return from a call to SSL_get_servername
  2505.       return s->session && !s->ext.hostname ?
  2506.           s->session->ext.hostname : s->ext.hostname;
  2507. > }
  2508.   
  2509.   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:3908:1: start of procedure SSL_get_ex_data()
  3906.   }
  3907.   
  3908. > void *SSL_get_ex_data(const SSL *s, int idx)
  3909.   {
  3910.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:3910:5: 
  3908.   void *SSL_get_ex_data(const SSL *s, int idx)
  3909.   {
  3910. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  3911.   }
  3912.   

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:3911:1: return from a call to SSL_get_ex_data
  3909.   {
  3910.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  3911. > }
  3912.   
  3913.   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:3745:1: start of procedure SSL_set_SSL_CTX()
  3743.   }
  3744.   
  3745. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3746.   {
  3747.       CERT *new_cert;

ssl/ssl_lib.c:3748:9: Taking false branch
  3746.   {
  3747.       CERT *new_cert;
  3748.       if (ssl->ctx == ctx)
                  ^
  3749.           return ssl->ctx;
  3750.       if (ctx == NULL)

ssl/ssl_lib.c:3750:9: Taking false branch
  3748.       if (ssl->ctx == ctx)
  3749.           return ssl->ctx;
  3750.       if (ctx == NULL)
                  ^
  3751.           ctx = ssl->session_ctx;
  3752.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3752:5: Skipping ssl_cert_dup(): empty list of specs
  3750.       if (ctx == NULL)
  3751.           ctx = ssl->session_ctx;
  3752.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3753.       if (new_cert == NULL) {
  3754.           return NULL;

ssl/ssl_lib.c:3753:9: Taking false branch
  3751.           ctx = ssl->session_ctx;
  3752.       new_cert = ssl_cert_dup(ctx->cert);
  3753.       if (new_cert == NULL) {
                  ^
  3754.           return NULL;
  3755.       }

ssl/ssl_lib.c:3757:10: Taking false branch
  3755.       }
  3756.   
  3757.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3758.           ssl_cert_free(new_cert);
  3759.           return NULL;

ssl/ssl_lib.c:3762:5: 
  3760.       }
  3761.   
  3762. >     ssl_cert_free(ssl->cert);
  3763.       ssl->cert = new_cert;
  3764.   

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:3763:5: 
  3761.   
  3762.       ssl_cert_free(ssl->cert);
  3763. >     ssl->cert = new_cert;
  3764.   
  3765.       /*

ssl/ssl_lib.c:3769:10: Condition is false
  3767.        * so setter APIs must prevent invalid lengths from entering the system.
  3768.        */
  3769.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3770.           return NULL;
  3771.   

ssl/ssl_lib.c:3769:10: Taking true branch
  3767.        * so setter APIs must prevent invalid lengths from entering the system.
  3768.        */
  3769.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3770.           return NULL;
  3771.   

ssl/ssl_lib.c:3770:9: 
  3768.        */
  3769.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3770. >         return NULL;
  3771.   
  3772.       /*

ssl/ssl_lib.c:3790:1: return from a call to SSL_set_SSL_CTX
  3788.   
  3789.       return ssl->ctx;
  3790. > }
  3791.   
  3792.   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:4326:1: start of procedure SSL_clear_options()
  4324.   }
  4325.   
  4326. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4327.   {
  4328.       return s->options &= ~op;

ssl/ssl_lib.c:4328:5: 
  4326.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4327.   {
  4328. >     return s->options &= ~op;
  4329.   }
  4330.   

ssl/ssl_lib.c:4329:1: return from a call to SSL_clear_options
  4327.   {
  4328.       return s->options &= ~op;
  4329. > }
  4330.   
  4331.   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:4301:1: start of procedure SSL_CTX_get_options()
  4299.    * control interface.
  4300.    */
  4301. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4302.   {
  4303.       return ctx->options;

ssl/ssl_lib.c:4303:5: 
  4301.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4302.   {
  4303. >     return ctx->options;
  4304.   }
  4305.   

ssl/ssl_lib.c:4304:1: return from a call to SSL_CTX_get_options
  4302.   {
  4303.       return ctx->options;
  4304. > }
  4305.   
  4306.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4316:1: start of procedure SSL_set_options()
  4314.   }
  4315.   
  4316. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4317.   {
  4318.       return s->options |= op;

ssl/ssl_lib.c:4318:5: 
  4316.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4317.   {
  4318. >     return s->options |= op;
  4319.   }
  4320.   

ssl/ssl_lib.c:4319:1: return from a call to SSL_set_options
  4317.   {
  4318.       return s->options |= op;
  4319. > }
  4320.   
  4321.   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) {
