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 45 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:2683:1: start of procedure SSL_get_servername()
  2681.    */
  2682.   
  2683. > const char *SSL_get_servername(const SSL *s, const int type)
  2684.   {
  2685.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2685:9: Taking false branch
  2683.   const char *SSL_get_servername(const SSL *s, const int type)
  2684.   {
  2685.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2686.           return NULL;
  2687.   

ssl/ssl_lib.c:2688:12: Condition is true
  2686.           return NULL;
  2687.   
  2688.       return s->session && !s->ext.hostname ?
                     ^
  2689.           s->session->ext.hostname : s->ext.hostname;
  2690.   }

ssl/ssl_lib.c:2688:27: Condition is true
  2686.           return NULL;
  2687.   
  2688.       return s->session && !s->ext.hostname ?
                                    ^
  2689.           s->session->ext.hostname : s->ext.hostname;
  2690.   }

ssl/ssl_lib.c:2688:12: 
  2686.           return NULL;
  2687.   
  2688. >     return s->session && !s->ext.hostname ?
  2689.           s->session->ext.hostname : s->ext.hostname;
  2690.   }

ssl/ssl_lib.c:2688:5: 
  2686.           return NULL;
  2687.   
  2688. >     return s->session && !s->ext.hostname ?
  2689.           s->session->ext.hostname : s->ext.hostname;
  2690.   }

ssl/ssl_lib.c:2690:1: return from a call to SSL_get_servername
  2688.       return s->session && !s->ext.hostname ?
  2689.           s->session->ext.hostname : s->ext.hostname;
  2690. > }
  2691.   
  2692.   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:4154:1: start of procedure SSL_get_ex_data()
  4152.   }
  4153.   
  4154. > void *SSL_get_ex_data(const SSL *s, int idx)
  4155.   {
  4156.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4156:5: 
  4154.   void *SSL_get_ex_data(const SSL *s, int idx)
  4155.   {
  4156. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4157.   }
  4158.   

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:4157:1: return from a call to SSL_get_ex_data
  4155.   {
  4156.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4157. > }
  4158.   
  4159.   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:3991:1: start of procedure SSL_set_SSL_CTX()
  3989.   }
  3990.   
  3991. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3992.   {
  3993.       CERT *new_cert;

ssl/ssl_lib.c:3994:9: Taking false branch
  3992.   {
  3993.       CERT *new_cert;
  3994.       if (ssl->ctx == ctx)
                  ^
  3995.           return ssl->ctx;
  3996.       if (ctx == NULL)

ssl/ssl_lib.c:3996:9: Taking false branch
  3994.       if (ssl->ctx == ctx)
  3995.           return ssl->ctx;
  3996.       if (ctx == NULL)
                  ^
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3998:5: Skipping ssl_cert_dup(): empty list of specs
  3996.       if (ctx == NULL)
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3999.       if (new_cert == NULL) {
  4000.           return NULL;

ssl/ssl_lib.c:3999:9: Taking false branch
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);
  3999.       if (new_cert == NULL) {
                  ^
  4000.           return NULL;
  4001.       }

ssl/ssl_lib.c:4003:10: Taking false branch
  4001.       }
  4002.   
  4003.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  4004.           ssl_cert_free(new_cert);
  4005.           return NULL;

ssl/ssl_lib.c:4008:5: Skipping ssl_cert_free(): empty list of specs
  4006.       }
  4007.   
  4008.       ssl_cert_free(ssl->cert);
              ^
  4009.       ssl->cert = new_cert;
  4010.   

ssl/ssl_lib.c:4009:5: 
  4007.   
  4008.       ssl_cert_free(ssl->cert);
  4009. >     ssl->cert = new_cert;
  4010.   
  4011.       /*

ssl/ssl_lib.c:4015:10: Condition is false
  4013.        * so setter APIs must prevent invalid lengths from entering the system.
  4014.        */
  4015.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4016.           return NULL;
  4017.   

ssl/ssl_lib.c:4015:10: Taking true branch
  4013.        * so setter APIs must prevent invalid lengths from entering the system.
  4014.        */
  4015.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4016.           return NULL;
  4017.   

ssl/ssl_lib.c:4016:9: 
  4014.        */
  4015.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  4016. >         return NULL;
  4017.   
  4018.       /*

ssl/ssl_lib.c:4036:1: return from a call to SSL_set_SSL_CTX
  4034.   
  4035.       return ssl->ctx;
  4036. > }
  4037.   
  4038.   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:4578:1: start of procedure SSL_clear_options()
  4576.   }
  4577.   
  4578. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4579.   {
  4580.       return s->options &= ~op;

ssl/ssl_lib.c:4580:5: 
  4578.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4579.   {
  4580. >     return s->options &= ~op;
  4581.   }
  4582.   

ssl/ssl_lib.c:4581:1: return from a call to SSL_clear_options
  4579.   {
  4580.       return s->options &= ~op;
  4581. > }
  4582.   
  4583.   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:4553:1: start of procedure SSL_CTX_get_options()
  4551.    * control interface.
  4552.    */
  4553. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4554.   {
  4555.       return ctx->options;

ssl/ssl_lib.c:4555:5: 
  4553.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4554.   {
  4555. >     return ctx->options;
  4556.   }
  4557.   

ssl/ssl_lib.c:4556:1: return from a call to SSL_CTX_get_options
  4554.   {
  4555.       return ctx->options;
  4556. > }
  4557.   
  4558.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4568:1: start of procedure SSL_set_options()
  4566.   }
  4567.   
  4568. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4569.   {
  4570.       return s->options |= op;

ssl/ssl_lib.c:4570:5: 
  4568.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4569.   {
  4570. >     return s->options |= op;
  4571.   }
  4572.   

ssl/ssl_lib.c:4571:1: return from a call to SSL_set_options
  4569.   {
  4570.       return s->options |= op;
  4571. > }
  4572.   
  4573.   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) {
