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


test/handshake_helper.c:86:1: start of procedure select_server_ctx()
84.    * An empty SNI extension also returns SSL_TSLEXT_ERR_NOACK.
85.    */
86. > static int select_server_ctx(SSL *s, void *arg, int ignore)
87.   {
88.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);

test/handshake_helper.c:88:5: 
86.   static int select_server_ctx(SSL *s, void *arg, int ignore)
87.   {
88. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
89.       HANDSHAKE_EX_DATA *ex_data =
90.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));

ssl/ssl_lib.c:2084:1: start of procedure SSL_get_servername()
  2082.    */
  2083.   
  2084. > const char *SSL_get_servername(const SSL *s, const int type)
  2085.   {
  2086.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2086:9: Taking false branch
  2084.   const char *SSL_get_servername(const SSL *s, const int type)
  2085.   {
  2086.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2087.           return NULL;
  2088.   

ssl/ssl_lib.c:2089:12: Condition is true
  2087.           return NULL;
  2088.   
  2089.       return s->session && !s->tlsext_hostname ?
                     ^
  2090.           s->session->tlsext_hostname : s->tlsext_hostname;
  2091.   }

ssl/ssl_lib.c:2089:27: Condition is true
  2087.           return NULL;
  2088.   
  2089.       return s->session && !s->tlsext_hostname ?
                                    ^
  2090.           s->session->tlsext_hostname : s->tlsext_hostname;
  2091.   }

ssl/ssl_lib.c:2089:12: 
  2087.           return NULL;
  2088.   
  2089. >     return s->session && !s->tlsext_hostname ?
  2090.           s->session->tlsext_hostname : s->tlsext_hostname;
  2091.   }

ssl/ssl_lib.c:2089:5: 
  2087.           return NULL;
  2088.   
  2089. >     return s->session && !s->tlsext_hostname ?
  2090.           s->session->tlsext_hostname : s->tlsext_hostname;
  2091.   }

ssl/ssl_lib.c:2091:1: return from a call to SSL_get_servername
  2089.       return s->session && !s->tlsext_hostname ?
  2090.           s->session->tlsext_hostname : s->tlsext_hostname;
  2091. > }
  2092.   
  2093.   int SSL_get_servername_type(const SSL *s)

test/handshake_helper.c:89:5: 
87.   {
88.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
89. >     HANDSHAKE_EX_DATA *ex_data =
90.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
91.   

ssl/ssl_lib.c:3529:1: start of procedure SSL_get_ex_data()
  3527.   }
  3528.   
  3529. > void *SSL_get_ex_data(const SSL *s, int idx)
  3530.   {
  3531.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3531:5: 
  3529.   void *SSL_get_ex_data(const SSL *s, int idx)
  3530.   {
  3531. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3532.   }
  3533.   

crypto/ex_data.c:374:1: start of procedure CRYPTO_get_ex_data()
    372.    * particular index in the class used by this variable
    373.    */
    374. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    375.   {
    376.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:376:9: Taking true branch
    374.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    375.   {
    376.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    377.           return NULL;
    378.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:377:9: 
    375.   {
    376.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    377. >         return NULL;
    378.       return sk_void_value(ad->sk, idx);
    379.   }

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

ssl/ssl_lib.c:3532:1: return from a call to SSL_get_ex_data
  3530.   {
  3531.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3532. > }
  3533.   
  3534.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:92:9: Taking false branch
90.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
91.   
92.       if (servername == NULL) {
              ^
93.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
94.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:97:9: Taking true branch
95.       }
96.   
97.       if (strcmp(servername, "server2") == 0) {
               ^
98.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
99.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:98:9: 
96.   
97.       if (strcmp(servername, "server2") == 0) {
98. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
99.           SSL_set_SSL_CTX(s, new_ctx);
100.           /*

test/handshake_helper.c:99:9: 
97.       if (strcmp(servername, "server2") == 0) {
98.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
99. >         SSL_set_SSL_CTX(s, new_ctx);
100.           /*
101.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3381:1: start of procedure SSL_set_SSL_CTX()
  3379.   }
  3380.   
  3381. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3382.   {
  3383.       CERT *new_cert;

ssl/ssl_lib.c:3384:9: Taking false branch
  3382.   {
  3383.       CERT *new_cert;
  3384.       if (ssl->ctx == ctx)
                  ^
  3385.           return ssl->ctx;
  3386.       if (ctx == NULL)

ssl/ssl_lib.c:3386:9: Taking false branch
  3384.       if (ssl->ctx == ctx)
  3385.           return ssl->ctx;
  3386.       if (ctx == NULL)
                  ^
  3387.           ctx = ssl->initial_ctx;
  3388.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3388:5: Skipping ssl_cert_dup(): empty list of specs
  3386.       if (ctx == NULL)
  3387.           ctx = ssl->initial_ctx;
  3388.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3389.       if (new_cert == NULL) {
  3390.           return NULL;

ssl/ssl_lib.c:3389:9: Taking true branch
  3387.           ctx = ssl->initial_ctx;
  3388.       new_cert = ssl_cert_dup(ctx->cert);
  3389.       if (new_cert == NULL) {
                  ^
  3390.           return NULL;
  3391.       }

ssl/ssl_lib.c:3390:9: 
  3388.       new_cert = ssl_cert_dup(ctx->cert);
  3389.       if (new_cert == NULL) {
  3390. >         return NULL;
  3391.       }
  3392.       ssl_cert_free(ssl->cert);

ssl/ssl_lib.c:3419:1: return from a call to SSL_set_SSL_CTX
  3417.   
  3418.       return ssl->ctx;
  3419. > }
  3420.   
  3421.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:105:9: 
103.            * contexts differ/conflict
104.            */
105. >         SSL_clear_options(s, 0xFFFFFFFFL);
106.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
107.   

ssl/ssl_lib.c:3884:1: start of procedure SSL_clear_options()
  3882.       return ctx->options &= ~op;
  3883.   }
  3884. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  3885.   {
  3886.       return s->options &= ~op;

ssl/ssl_lib.c:3886:5: 
  3884.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  3885.   {
  3886. >     return s->options &= ~op;
  3887.   }
  3888.   

ssl/ssl_lib.c:3887:1: return from a call to SSL_clear_options
  3885.   {
  3886.       return s->options &= ~op;
  3887. > }
  3888.   
  3889.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:106:9: 
104.            */
105.           SSL_clear_options(s, 0xFFFFFFFFL);
106. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
107.   
108.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:3864:1: start of procedure SSL_CTX_get_options()
  3862.    * control interface.
  3863.    */
  3864. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  3865.   {
  3866.       return ctx->options;

ssl/ssl_lib.c:3866:5: 
  3864.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  3865.   {
  3866. >     return ctx->options;
  3867.   }
  3868.   unsigned long SSL_get_options(const SSL* s)

ssl/ssl_lib.c:3867:1: return from a call to SSL_CTX_get_options
  3865.   {
  3866.       return ctx->options;
  3867. > }
  3868.   unsigned long SSL_get_options(const SSL* s)
  3869.   {

ssl/ssl_lib.c:3876:1: start of procedure SSL_set_options()
  3874.       return ctx->options |= op;
  3875.   }
  3876. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  3877.   {
  3878.       return s->options |= op;

ssl/ssl_lib.c:3878:5: 
  3876.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  3877.   {
  3878. >     return s->options |= op;
  3879.   }
  3880.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

ssl/ssl_lib.c:3879:1: return from a call to SSL_set_options
  3877.   {
  3878.       return s->options |= op;
  3879. > }
  3880.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)
  3881.   {

test/handshake_helper.c:108:9: 
106.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
107.   
108. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
109.           return SSL_TLSEXT_ERR_OK;
110.       } else if (strcmp(servername, "server1") == 0) {
