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


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

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

ssl/ssl_lib.c:2355:1: start of procedure SSL_get_servername()
  2353.    */
  2354.   
  2355. > const char *SSL_get_servername(const SSL *s, const int type)
  2356.   {
  2357.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2357:9: Taking false branch
  2355.   const char *SSL_get_servername(const SSL *s, const int type)
  2356.   {
  2357.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2358.           return NULL;
  2359.   

ssl/ssl_lib.c:2360:12: Condition is true
  2358.           return NULL;
  2359.   
  2360.       return s->session && !s->ext.hostname ?
                     ^
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:27: Condition is true
  2358.           return NULL;
  2359.   
  2360.       return s->session && !s->ext.hostname ?
                                    ^
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:12: 
  2358.           return NULL;
  2359.   
  2360. >     return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:5: 
  2358.           return NULL;
  2359.   
  2360. >     return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2362:1: return from a call to SSL_get_servername
  2360.       return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362. > }
  2363.   
  2364.   int SSL_get_servername_type(const SSL *s)

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

ssl/ssl_lib.c:3745:1: start of procedure SSL_get_ex_data()
  3743.   }
  3744.   
  3745. > void *SSL_get_ex_data(const SSL *s, int idx)
  3746.   {
  3747.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3747:5: 
  3745.   void *SSL_get_ex_data(const SSL *s, int idx)
  3746.   {
  3747. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3748.   }
  3749.   

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:3748:1: return from a call to SSL_get_ex_data
  3746.   {
  3747.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3748. > }
  3749.   
  3750.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

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

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