test/handshake_helper.c:139: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 117 could be null and is dereferenced at line 139, column 9.
Showing all 19 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 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 true 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:139:9: 
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;
141.       } else if (ignore) {
