test/handshake_helper.c:142: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 117 could be null and is dereferenced at line 142, column 9.
Showing all 20 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:2687:1: start of procedure SSL_get_servername()
  2685.    */
  2686.   
  2687. > const char *SSL_get_servername(const SSL *s, const int type)
  2688.   {
  2689.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2689:9: Taking false branch
  2687.   const char *SSL_get_servername(const SSL *s, const int type)
  2688.   {
  2689.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2690.           return NULL;
  2691.   

ssl/ssl_lib.c:2698:9: Taking true branch
  2696.        * might error out if there is not a SNI value available.
  2697.        */
  2698.       if (s->hit)
                  ^
  2699.           return s->session->ext.hostname;
  2700.       return s->ext.hostname;

ssl/ssl_lib.c:2699:9: 
  2697.        */
  2698.       if (s->hit)
  2699. >         return s->session->ext.hostname;
  2700.       return s->ext.hostname;
  2701.   }

ssl/ssl_lib.c:2701:1: return from a call to SSL_get_servername
  2699.           return s->session->ext.hostname;
  2700.       return s->ext.hostname;
  2701. > }
  2702.   
  2703.   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:4215:1: start of procedure SSL_get_ex_data()
  4213.   }
  4214.   
  4215. > void *SSL_get_ex_data(const SSL *s, int idx)
  4216.   {
  4217.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4217:5: 
  4215.   void *SSL_get_ex_data(const SSL *s, int idx)
  4216.   {
  4217. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4218.   }
  4219.   

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:4218:1: return from a call to SSL_get_ex_data
  4216.   {
  4217.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4218. > }
  4219.   
  4220.   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 false 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:138:16: Taking false branch
136.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
137.           return SSL_TLSEXT_ERR_OK;
138.       } else if (strcmp(servername, "server1") == 0) {
                      ^
139.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
140.           return SSL_TLSEXT_ERR_OK;

test/handshake_helper.c:141:16: Taking true branch
139.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
140.           return SSL_TLSEXT_ERR_OK;
141.       } else if (ignore) {
                      ^
142.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
143.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:142:9: 
140.           return SSL_TLSEXT_ERR_OK;
141.       } else if (ignore) {
142. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
143.           return SSL_TLSEXT_ERR_NOACK;
144.       } else {
