test/handshake_helper.c:128: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 109 could be null and is dereferenced at line 128, column 9.
Showing all 49 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:2372:1: start of procedure SSL_get_servername()
  2370.    */
  2371.   
  2372. > const char *SSL_get_servername(const SSL *s, const int type)
  2373.   {
  2374.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2374:9: Taking false branch
  2372.   const char *SSL_get_servername(const SSL *s, const int type)
  2373.   {
  2374.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2375.           return NULL;
  2376.   

ssl/ssl_lib.c:2377:12: Condition is true
  2375.           return NULL;
  2376.   
  2377.       return s->session && !s->ext.hostname ?
                     ^
  2378.           s->session->ext.hostname : s->ext.hostname;
  2379.   }

ssl/ssl_lib.c:2377:27: Condition is true
  2375.           return NULL;
  2376.   
  2377.       return s->session && !s->ext.hostname ?
                                    ^
  2378.           s->session->ext.hostname : s->ext.hostname;
  2379.   }

ssl/ssl_lib.c:2377:12: 
  2375.           return NULL;
  2376.   
  2377. >     return s->session && !s->ext.hostname ?
  2378.           s->session->ext.hostname : s->ext.hostname;
  2379.   }

ssl/ssl_lib.c:2377:5: 
  2375.           return NULL;
  2376.   
  2377. >     return s->session && !s->ext.hostname ?
  2378.           s->session->ext.hostname : s->ext.hostname;
  2379.   }

ssl/ssl_lib.c:2379:1: return from a call to SSL_get_servername
  2377.       return s->session && !s->ext.hostname ?
  2378.           s->session->ext.hostname : s->ext.hostname;
  2379. > }
  2380.   
  2381.   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: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: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: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: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 true 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:118:9: 
116.   
117.       if (strcmp(servername, "server2") == 0) {
118. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
119.           SSL_set_SSL_CTX(s, new_ctx);
120.           /*

test/handshake_helper.c:119:9: 
117.       if (strcmp(servername, "server2") == 0) {
118.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
119. >         SSL_set_SSL_CTX(s, new_ctx);
120.           /*
121.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3594:1: start of procedure SSL_set_SSL_CTX()
  3592.   }
  3593.   
  3594. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3595.   {
  3596.       CERT *new_cert;

ssl/ssl_lib.c:3597:9: Taking false branch
  3595.   {
  3596.       CERT *new_cert;
  3597.       if (ssl->ctx == ctx)
                  ^
  3598.           return ssl->ctx;
  3599.       if (ctx == NULL)

ssl/ssl_lib.c:3599:9: Taking false branch
  3597.       if (ssl->ctx == ctx)
  3598.           return ssl->ctx;
  3599.       if (ctx == NULL)
                  ^
  3600.           ctx = ssl->session_ctx;
  3601.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3601:5: Skipping ssl_cert_dup(): empty list of specs
  3599.       if (ctx == NULL)
  3600.           ctx = ssl->session_ctx;
  3601.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3602.       if (new_cert == NULL) {
  3603.           return NULL;

ssl/ssl_lib.c:3602:9: Taking false branch
  3600.           ctx = ssl->session_ctx;
  3601.       new_cert = ssl_cert_dup(ctx->cert);
  3602.       if (new_cert == NULL) {
                  ^
  3603.           return NULL;
  3604.       }

ssl/ssl_lib.c:3606:10: Taking false branch
  3604.       }
  3605.   
  3606.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3607.           ssl_cert_free(new_cert);
  3608.           return NULL;

ssl/ssl_lib.c:3611:5: 
  3609.       }
  3610.   
  3611. >     ssl_cert_free(ssl->cert);
  3612.       ssl->cert = new_cert;
  3613.   

ssl/ssl_cert.c:231:1: start of procedure ssl_cert_free()
    229.   }
    230.   
    231. > void ssl_cert_free(CERT *c)
    232.   {
    233.       int i;

ssl/ssl_cert.c:235:9: Taking true branch
    233.       int i;
    234.   
    235.       if (c == NULL)
                   ^
    236.           return;
    237.   

ssl/ssl_cert.c:236:9: 
    234.   
    235.       if (c == NULL)
    236. >         return;
    237.   
    238.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

ssl/ssl_cert.c:261:1: return from a call to ssl_cert_free
    259.       CRYPTO_THREAD_lock_free(c->lock);
    260.       OPENSSL_free(c);
    261. > }
    262.   
    263.   int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain)

ssl/ssl_lib.c:3612:5: 
  3610.   
  3611.       ssl_cert_free(ssl->cert);
  3612. >     ssl->cert = new_cert;
  3613.   
  3614.       /*

ssl/ssl_lib.c:3618:10: Condition is false
  3616.        * so setter APIs must prevent invalid lengths from entering the system.
  3617.        */
  3618.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3619.           return NULL;
  3620.   

ssl/ssl_lib.c:3618:10: Taking true branch
  3616.        * so setter APIs must prevent invalid lengths from entering the system.
  3617.        */
  3618.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3619.           return NULL;
  3620.   

ssl/ssl_lib.c:3619:9: 
  3617.        */
  3618.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3619. >         return NULL;
  3620.   
  3621.       /*

ssl/ssl_lib.c:3639:1: return from a call to SSL_set_SSL_CTX
  3637.   
  3638.       return ssl->ctx;
  3639. > }
  3640.   
  3641.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:125:9: 
123.            * contexts differ/conflict
124.            */
125. >         SSL_clear_options(s, 0xFFFFFFFFL);
126.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
127.   

ssl/ssl_lib.c:4141:1: start of procedure SSL_clear_options()
  4139.   }
  4140.   
  4141. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4142.   {
  4143.       return s->options &= ~op;

ssl/ssl_lib.c:4143:5: 
  4141.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4142.   {
  4143. >     return s->options &= ~op;
  4144.   }
  4145.   

ssl/ssl_lib.c:4144:1: return from a call to SSL_clear_options
  4142.   {
  4143.       return s->options &= ~op;
  4144. > }
  4145.   
  4146.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:126:9: 
124.            */
125.           SSL_clear_options(s, 0xFFFFFFFFL);
126. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
127.   
128.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4116:1: start of procedure SSL_CTX_get_options()
  4114.    * control interface.
  4115.    */
  4116. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4117.   {
  4118.       return ctx->options;

ssl/ssl_lib.c:4118:5: 
  4116.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4117.   {
  4118. >     return ctx->options;
  4119.   }
  4120.   

ssl/ssl_lib.c:4119:1: return from a call to SSL_CTX_get_options
  4117.   {
  4118.       return ctx->options;
  4119. > }
  4120.   
  4121.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4131:1: start of procedure SSL_set_options()
  4129.   }
  4130.   
  4131. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4132.   {
  4133.       return s->options |= op;

ssl/ssl_lib.c:4133:5: 
  4131.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4132.   {
  4133. >     return s->options |= op;
  4134.   }
  4135.   

ssl/ssl_lib.c:4134:1: return from a call to SSL_set_options
  4132.   {
  4133.       return s->options |= op;
  4134. > }
  4135.   
  4136.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

test/handshake_helper.c:128:9: 
126.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
127.   
128. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
129.           return SSL_TLSEXT_ERR_OK;
130.       } else if (strcmp(servername, "server1") == 0) {
