test/handshake_helper.c:129: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 107 could be null and is dereferenced at line 129, column 9.
Showing all 21 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 false 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:128:16: Taking true branch
126.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
127.           return SSL_TLSEXT_ERR_OK;
128.       } else if (strcmp(servername, "server1") == 0) {
                      ^
129.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
130.           return SSL_TLSEXT_ERR_OK;

test/handshake_helper.c:129:9: 
127.           return SSL_TLSEXT_ERR_OK;
128.       } else if (strcmp(servername, "server1") == 0) {
129. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
130.           return SSL_TLSEXT_ERR_OK;
131.       } else if (ignore) {
