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:2597:1: start of procedure SSL_get_servername()
  2595.    */
  2596.   
  2597. > const char *SSL_get_servername(const SSL *s, const int type)
  2598.   {
  2599.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2599:9: Taking false branch
  2597.   const char *SSL_get_servername(const SSL *s, const int type)
  2598.   {
  2599.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2600.           return NULL;
  2601.   

ssl/ssl_lib.c:2602:12: Condition is true
  2600.           return NULL;
  2601.   
  2602.       return s->session && !s->ext.hostname ?
                     ^
  2603.           s->session->ext.hostname : s->ext.hostname;
  2604.   }

ssl/ssl_lib.c:2602:27: Condition is true
  2600.           return NULL;
  2601.   
  2602.       return s->session && !s->ext.hostname ?
                                    ^
  2603.           s->session->ext.hostname : s->ext.hostname;
  2604.   }

ssl/ssl_lib.c:2602:12: 
  2600.           return NULL;
  2601.   
  2602. >     return s->session && !s->ext.hostname ?
  2603.           s->session->ext.hostname : s->ext.hostname;
  2604.   }

ssl/ssl_lib.c:2602:5: 
  2600.           return NULL;
  2601.   
  2602. >     return s->session && !s->ext.hostname ?
  2603.           s->session->ext.hostname : s->ext.hostname;
  2604.   }

ssl/ssl_lib.c:2604:1: return from a call to SSL_get_servername
  2602.       return s->session && !s->ext.hostname ?
  2603.           s->session->ext.hostname : s->ext.hostname;
  2604. > }
  2605.   
  2606.   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:4014:1: start of procedure SSL_get_ex_data()
  4012.   }
  4013.   
  4014. > void *SSL_get_ex_data(const SSL *s, int idx)
  4015.   {
  4016.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4016:5: 
  4014.   void *SSL_get_ex_data(const SSL *s, int idx)
  4015.   {
  4016. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4017.   }
  4018.   

crypto/ex_data.c:393:1: start of procedure CRYPTO_get_ex_data()
    391.    * particular index in the class used by this variable
    392.    */
    393. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:395:9: Taking true branch
    393.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    396.           return NULL;
    397.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:396:9: 
    394.   {
    395.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    396. >         return NULL;
    397.       return sk_void_value(ad->sk, idx);
    398.   }

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

ssl/ssl_lib.c:4017:1: return from a call to SSL_get_ex_data
  4015.   {
  4016.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4017. > }
  4018.   
  4019.   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:3851:1: start of procedure SSL_set_SSL_CTX()
  3849.   }
  3850.   
  3851. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3852.   {
  3853.       CERT *new_cert;

ssl/ssl_lib.c:3854:9: Taking false branch
  3852.   {
  3853.       CERT *new_cert;
  3854.       if (ssl->ctx == ctx)
                  ^
  3855.           return ssl->ctx;
  3856.       if (ctx == NULL)

ssl/ssl_lib.c:3856:9: Taking false branch
  3854.       if (ssl->ctx == ctx)
  3855.           return ssl->ctx;
  3856.       if (ctx == NULL)
                  ^
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3858:5: Skipping ssl_cert_dup(): empty list of specs
  3856.       if (ctx == NULL)
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3859.       if (new_cert == NULL) {
  3860.           return NULL;

ssl/ssl_lib.c:3859:9: Taking false branch
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);
  3859.       if (new_cert == NULL) {
                  ^
  3860.           return NULL;
  3861.       }

ssl/ssl_lib.c:3863:10: Taking false branch
  3861.       }
  3862.   
  3863.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3864.           ssl_cert_free(new_cert);
  3865.           return NULL;

ssl/ssl_lib.c:3868:5: 
  3866.       }
  3867.   
  3868. >     ssl_cert_free(ssl->cert);
  3869.       ssl->cert = new_cert;
  3870.   

ssl/ssl_cert.c:224:1: start of procedure ssl_cert_free()
    222.   }
    223.   
    224. > void ssl_cert_free(CERT *c)
    225.   {
    226.       int i;

ssl/ssl_cert.c:228:9: Taking true branch
    226.       int i;
    227.   
    228.       if (c == NULL)
                   ^
    229.           return;
    230.   

ssl/ssl_cert.c:229:9: 
    227.   
    228.       if (c == NULL)
    229. >         return;
    230.   
    231.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

ssl/ssl_cert.c:254:1: return from a call to ssl_cert_free
    252.       CRYPTO_THREAD_lock_free(c->lock);
    253.       OPENSSL_free(c);
    254. > }
    255.   
    256.   int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain)

ssl/ssl_lib.c:3869:5: 
  3867.   
  3868.       ssl_cert_free(ssl->cert);
  3869. >     ssl->cert = new_cert;
  3870.   
  3871.       /*

ssl/ssl_lib.c:3875:10: Condition is false
  3873.        * so setter APIs must prevent invalid lengths from entering the system.
  3874.        */
  3875.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3876.           return NULL;
  3877.   

ssl/ssl_lib.c:3875:10: Taking true branch
  3873.        * so setter APIs must prevent invalid lengths from entering the system.
  3874.        */
  3875.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3876.           return NULL;
  3877.   

ssl/ssl_lib.c:3876:9: 
  3874.        */
  3875.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3876. >         return NULL;
  3877.   
  3878.       /*

ssl/ssl_lib.c:3896:1: return from a call to SSL_set_SSL_CTX
  3894.   
  3895.       return ssl->ctx;
  3896. > }
  3897.   
  3898.   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:4438:1: start of procedure SSL_clear_options()
  4436.   }
  4437.   
  4438. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4439.   {
  4440.       return s->options &= ~op;

ssl/ssl_lib.c:4440:5: 
  4438.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4439.   {
  4440. >     return s->options &= ~op;
  4441.   }
  4442.   

ssl/ssl_lib.c:4441:1: return from a call to SSL_clear_options
  4439.   {
  4440.       return s->options &= ~op;
  4441. > }
  4442.   
  4443.   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:4413:1: start of procedure SSL_CTX_get_options()
  4411.    * control interface.
  4412.    */
  4413. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4414.   {
  4415.       return ctx->options;

ssl/ssl_lib.c:4415:5: 
  4413.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4414.   {
  4415. >     return ctx->options;
  4416.   }
  4417.   

ssl/ssl_lib.c:4416:1: return from a call to SSL_CTX_get_options
  4414.   {
  4415.       return ctx->options;
  4416. > }
  4417.   
  4418.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4428:1: start of procedure SSL_set_options()
  4426.   }
  4427.   
  4428. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4429.   {
  4430.       return s->options |= op;

ssl/ssl_lib.c:4430:5: 
  4428.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4429.   {
  4430. >     return s->options |= op;
  4431.   }
  4432.   

ssl/ssl_lib.c:4431:1: return from a call to SSL_set_options
  4429.   {
  4430.       return s->options |= op;
  4431. > }
  4432.   
  4433.   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) {
