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


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

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

ssl/ssl_lib.c:2366:1: start of procedure SSL_get_servername()
  2364.    */
  2365.   
  2366. > const char *SSL_get_servername(const SSL *s, const int type)
  2367.   {
  2368.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2368:9: Taking false branch
  2366.   const char *SSL_get_servername(const SSL *s, const int type)
  2367.   {
  2368.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2369.           return NULL;
  2370.   

ssl/ssl_lib.c:2371:12: Condition is true
  2369.           return NULL;
  2370.   
  2371.       return s->session && !s->ext.hostname ?
                     ^
  2372.           s->session->ext.hostname : s->ext.hostname;
  2373.   }

ssl/ssl_lib.c:2371:27: Condition is true
  2369.           return NULL;
  2370.   
  2371.       return s->session && !s->ext.hostname ?
                                    ^
  2372.           s->session->ext.hostname : s->ext.hostname;
  2373.   }

ssl/ssl_lib.c:2371:12: 
  2369.           return NULL;
  2370.   
  2371. >     return s->session && !s->ext.hostname ?
  2372.           s->session->ext.hostname : s->ext.hostname;
  2373.   }

ssl/ssl_lib.c:2371:5: 
  2369.           return NULL;
  2370.   
  2371. >     return s->session && !s->ext.hostname ?
  2372.           s->session->ext.hostname : s->ext.hostname;
  2373.   }

ssl/ssl_lib.c:2373:1: return from a call to SSL_get_servername
  2371.       return s->session && !s->ext.hostname ?
  2372.           s->session->ext.hostname : s->ext.hostname;
  2373. > }
  2374.   
  2375.   int SSL_get_servername_type(const SSL *s)

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

ssl/ssl_lib.c:3729:1: start of procedure SSL_get_ex_data()
  3727.   }
  3728.   
  3729. > void *SSL_get_ex_data(const SSL *s, int idx)
  3730.   {
  3731.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3731:5: 
  3729.   void *SSL_get_ex_data(const SSL *s, int idx)
  3730.   {
  3731. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3732.   }
  3733.   

crypto/ex_data.c:387:1: start of procedure CRYPTO_get_ex_data()
    385.    * particular index in the class used by this variable
    386.    */
    387. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:389:9: Taking true branch
    387.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    390.           return NULL;
    391.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:390:9: 
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    390. >         return NULL;
    391.       return sk_void_value(ad->sk, idx);
    392.   }

crypto/ex_data.c:392:1: return from a call to CRYPTO_get_ex_data
    390.           return NULL;
    391.       return sk_void_value(ad->sk, idx);
    392. > }

ssl/ssl_lib.c:3732:1: return from a call to SSL_get_ex_data
  3730.   {
  3731.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3732. > }
  3733.   
  3734.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

test/handshake_helper.c:130:16: Taking false branch
128.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
129.           return SSL_TLSEXT_ERR_OK;
130.       } else if (strcmp(servername, "server1") == 0) {
                      ^
131.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
132.           return SSL_TLSEXT_ERR_OK;

test/handshake_helper.c:133:16: Taking true branch
131.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
132.           return SSL_TLSEXT_ERR_OK;
133.       } else if (ignore) {
                      ^
134.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
135.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:134:9: 
132.           return SSL_TLSEXT_ERR_OK;
133.       } else if (ignore) {
134. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
135.           return SSL_TLSEXT_ERR_NOACK;
136.       } else {
