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


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

test/handshake_helper.c:112:5: 
110.   static int select_server_ctx(SSL *s, void *arg, int ignore)
111.   {
112. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
113.       HANDSHAKE_EX_DATA *ex_data =
114.           (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:2608:9: Taking true branch
  2606.        * might error out if there is not a SNI value available.
  2607.        */
  2608.       if (s->hit)
                  ^
  2609.           return s->session->ext.hostname;
  2610.       return s->ext.hostname;

ssl/ssl_lib.c:2609:9: 
  2607.        */
  2608.       if (s->hit)
  2609. >         return s->session->ext.hostname;
  2610.       return s->ext.hostname;
  2611.   }

ssl/ssl_lib.c:2611:1: return from a call to SSL_get_servername
  2609.           return s->session->ext.hostname;
  2610.       return s->ext.hostname;
  2611. > }
  2612.   
  2613.   int SSL_get_servername_type(const SSL *s)

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

ssl/ssl_lib.c:4105:1: start of procedure SSL_get_ex_data()
  4103.   }
  4104.   
  4105. > void *SSL_get_ex_data(const SSL *s, int idx)
  4106.   {
  4107.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4107:5: 
  4105.   void *SSL_get_ex_data(const SSL *s, int idx)
  4106.   {
  4107. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4108.   }
  4109.   

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:4108:1: return from a call to SSL_get_ex_data
  4106.   {
  4107.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4108. > }
  4109.   
  4110.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

test/handshake_helper.c:121:9: Taking true branch
119.       }
120.   
121.       if (strcmp(servername, "server2") == 0) {
               ^
122.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
123.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:122:9: 
120.   
121.       if (strcmp(servername, "server2") == 0) {
122. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
123.           SSL_set_SSL_CTX(s, new_ctx);
124.           /*

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

ssl/ssl_lib.c:3942:1: start of procedure SSL_set_SSL_CTX()
  3940.   }
  3941.   
  3942. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3943.   {
  3944.       CERT *new_cert;

ssl/ssl_lib.c:3945:9: Taking false branch
  3943.   {
  3944.       CERT *new_cert;
  3945.       if (ssl->ctx == ctx)
                  ^
  3946.           return ssl->ctx;
  3947.       if (ctx == NULL)

ssl/ssl_lib.c:3947:9: Taking false branch
  3945.       if (ssl->ctx == ctx)
  3946.           return ssl->ctx;
  3947.       if (ctx == NULL)
                  ^
  3948.           ctx = ssl->session_ctx;
  3949.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3949:5: Skipping ssl_cert_dup(): empty list of specs
  3947.       if (ctx == NULL)
  3948.           ctx = ssl->session_ctx;
  3949.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3950.       if (new_cert == NULL) {
  3951.           return NULL;

ssl/ssl_lib.c:3950:9: Taking false branch
  3948.           ctx = ssl->session_ctx;
  3949.       new_cert = ssl_cert_dup(ctx->cert);
  3950.       if (new_cert == NULL) {
                  ^
  3951.           return NULL;
  3952.       }

ssl/ssl_lib.c:3954:10: Taking false branch
  3952.       }
  3953.   
  3954.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3955.           ssl_cert_free(new_cert);
  3956.           return NULL;

ssl/ssl_lib.c:3959:5: 
  3957.       }
  3958.   
  3959. >     ssl_cert_free(ssl->cert);
  3960.       ssl->cert = new_cert;
  3961.   

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.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

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

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

ssl/ssl_lib.c:3960:5: 
  3958.   
  3959.       ssl_cert_free(ssl->cert);
  3960. >     ssl->cert = new_cert;
  3961.   
  3962.       /*

ssl/ssl_lib.c:3966:10: Condition is false
  3964.        * so setter APIs must prevent invalid lengths from entering the system.
  3965.        */
  3966.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3967.           return NULL;
  3968.   

ssl/ssl_lib.c:3966:10: Taking true branch
  3964.        * so setter APIs must prevent invalid lengths from entering the system.
  3965.        */
  3966.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3967.           return NULL;
  3968.   

ssl/ssl_lib.c:3967:9: 
  3965.        */
  3966.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3967. >         return NULL;
  3968.   
  3969.       /*

ssl/ssl_lib.c:3987:1: return from a call to SSL_set_SSL_CTX
  3985.   
  3986.       return ssl->ctx;
  3987. > }
  3988.   
  3989.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:129:9: 
127.            * contexts differ/conflict
128.            */
129. >         SSL_clear_options(s, 0xFFFFFFFFL);
130.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
131.   

ssl/ssl_lib.c:4553:1: start of procedure SSL_clear_options()
  4551.   }
  4552.   
  4553. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4554.   {
  4555.       return s->options &= ~op;

ssl/ssl_lib.c:4555:5: 
  4553.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4554.   {
  4555. >     return s->options &= ~op;
  4556.   }
  4557.   

ssl/ssl_lib.c:4556:1: return from a call to SSL_clear_options
  4554.   {
  4555.       return s->options &= ~op;
  4556. > }
  4557.   
  4558.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:130:9: 
128.            */
129.           SSL_clear_options(s, 0xFFFFFFFFL);
130. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
131.   
132.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4528:1: start of procedure SSL_CTX_get_options()
  4526.    * control interface.
  4527.    */
  4528. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4529.   {
  4530.       return ctx->options;

ssl/ssl_lib.c:4530:5: 
  4528.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4529.   {
  4530. >     return ctx->options;
  4531.   }
  4532.   

ssl/ssl_lib.c:4531:1: return from a call to SSL_CTX_get_options
  4529.   {
  4530.       return ctx->options;
  4531. > }
  4532.   
  4533.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4543:1: start of procedure SSL_set_options()
  4541.   }
  4542.   
  4543. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4544.   {
  4545.       return s->options |= op;

ssl/ssl_lib.c:4545:5: 
  4543.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4544.   {
  4545. >     return s->options |= op;
  4546.   }
  4547.   

ssl/ssl_lib.c:4546:1: return from a call to SSL_set_options
  4544.   {
  4545.       return s->options |= op;
  4546. > }
  4547.   
  4548.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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