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


test/handshake_helper.c:52:1: start of procedure select_server_ctx()
50.    * An empty SNI extension also returns SSL_TSLEXT_ERR_NOACK.
51.    */
52. > static int select_server_ctx(SSL *s, void *arg, int ignore)
53.   {
54.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);

test/handshake_helper.c:54:5: 
52.   static int select_server_ctx(SSL *s, void *arg, int ignore)
53.   {
54. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
55.       HANDSHAKE_EX_DATA *ex_data =
56.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));

ssl/ssl_lib.c:2052:1: start of procedure SSL_get_servername()
  2050.    */
  2051.   
  2052. > const char *SSL_get_servername(const SSL *s, const int type)
  2053.   {
  2054.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2054:9: Taking false branch
  2052.   const char *SSL_get_servername(const SSL *s, const int type)
  2053.   {
  2054.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2055.           return NULL;
  2056.   

ssl/ssl_lib.c:2057:12: Condition is true
  2055.           return NULL;
  2056.   
  2057.       return s->session && !s->tlsext_hostname ?
                     ^
  2058.           s->session->tlsext_hostname : s->tlsext_hostname;
  2059.   }

ssl/ssl_lib.c:2057:27: Condition is true
  2055.           return NULL;
  2056.   
  2057.       return s->session && !s->tlsext_hostname ?
                                    ^
  2058.           s->session->tlsext_hostname : s->tlsext_hostname;
  2059.   }

ssl/ssl_lib.c:2057:12: 
  2055.           return NULL;
  2056.   
  2057. >     return s->session && !s->tlsext_hostname ?
  2058.           s->session->tlsext_hostname : s->tlsext_hostname;
  2059.   }

ssl/ssl_lib.c:2057:5: 
  2055.           return NULL;
  2056.   
  2057. >     return s->session && !s->tlsext_hostname ?
  2058.           s->session->tlsext_hostname : s->tlsext_hostname;
  2059.   }

ssl/ssl_lib.c:2059:1: return from a call to SSL_get_servername
  2057.       return s->session && !s->tlsext_hostname ?
  2058.           s->session->tlsext_hostname : s->tlsext_hostname;
  2059. > }
  2060.   
  2061.   int SSL_get_servername_type(const SSL *s)

test/handshake_helper.c:55:5: 
53.   {
54.       const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
55. >     HANDSHAKE_EX_DATA *ex_data =
56.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
57.   

ssl/ssl_lib.c:3496:1: start of procedure SSL_get_ex_data()
  3494.   }
  3495.   
  3496. > void *SSL_get_ex_data(const SSL *s, int idx)
  3497.   {
  3498.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3498:5: 
  3496.   void *SSL_get_ex_data(const SSL *s, int idx)
  3497.   {
  3498. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3499.   }
  3500.   

crypto/ex_data.c:369:1: start of procedure CRYPTO_get_ex_data()
    367.    * particular index in the class used by this variable
    368.    */
    369. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    370.   {
    371.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:371:9: Taking true branch
    369.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    370.   {
    371.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    372.           return NULL;
    373.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:372:9: 
    370.   {
    371.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    372. >         return NULL;
    373.       return sk_void_value(ad->sk, idx);
    374.   }

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

ssl/ssl_lib.c:3499:1: return from a call to SSL_get_ex_data
  3497.   {
  3498.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3499. > }
  3500.   
  3501.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:58:9: Taking false branch
56.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
57.   
58.       if (servername == NULL) {
              ^
59.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
60.           return SSL_TLSEXT_ERR_NOACK;

test/handshake_helper.c:63:9: Taking true branch
61.       }
62.   
63.       if (strcmp(servername, "server2") == 0) {
              ^
64.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
65.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:64:9: 
62.   
63.       if (strcmp(servername, "server2") == 0) {
64. >         SSL_CTX *new_ctx = (SSL_CTX*)arg;
65.           SSL_set_SSL_CTX(s, new_ctx);
66.           /*

test/handshake_helper.c:65:9: 
63.       if (strcmp(servername, "server2") == 0) {
64.           SSL_CTX *new_ctx = (SSL_CTX*)arg;
65. >         SSL_set_SSL_CTX(s, new_ctx);
66.           /*
67.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3348:1: start of procedure SSL_set_SSL_CTX()
  3346.   }
  3347.   
  3348. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3349.   {
  3350.       CERT *new_cert;

ssl/ssl_lib.c:3351:9: Taking false branch
  3349.   {
  3350.       CERT *new_cert;
  3351.       if (ssl->ctx == ctx)
                  ^
  3352.           return ssl->ctx;
  3353.       if (ctx == NULL)

ssl/ssl_lib.c:3353:9: Taking false branch
  3351.       if (ssl->ctx == ctx)
  3352.           return ssl->ctx;
  3353.       if (ctx == NULL)
                  ^
  3354.           ctx = ssl->initial_ctx;
  3355.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3355:5: Skipping ssl_cert_dup(): empty list of specs
  3353.       if (ctx == NULL)
  3354.           ctx = ssl->initial_ctx;
  3355.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3356.       if (new_cert == NULL) {
  3357.           return NULL;

ssl/ssl_lib.c:3356:9: Taking true branch
  3354.           ctx = ssl->initial_ctx;
  3355.       new_cert = ssl_cert_dup(ctx->cert);
  3356.       if (new_cert == NULL) {
                  ^
  3357.           return NULL;
  3358.       }

ssl/ssl_lib.c:3357:9: 
  3355.       new_cert = ssl_cert_dup(ctx->cert);
  3356.       if (new_cert == NULL) {
  3357. >         return NULL;
  3358.       }
  3359.       ssl_cert_free(ssl->cert);

ssl/ssl_lib.c:3386:1: return from a call to SSL_set_SSL_CTX
  3384.   
  3385.       return ssl->ctx;
  3386. > }
  3387.   
  3388.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:71:9: 
69.            * contexts differ/conflict
70.            */
71. >         SSL_clear_options(s, 0xFFFFFFFFL);
72.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
73.   

ssl/ssl_lib.c:3851:1: start of procedure SSL_clear_options()
  3849.       return ctx->options &= ~op;
  3850.   }
  3851. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  3852.   {
  3853.       return s->options &= ~op;

ssl/ssl_lib.c:3853:5: 
  3851.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  3852.   {
  3853. >     return s->options &= ~op;
  3854.   }
  3855.   

ssl/ssl_lib.c:3854:1: return from a call to SSL_clear_options
  3852.   {
  3853.       return s->options &= ~op;
  3854. > }
  3855.   
  3856.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:72:9: 
70.            */
71.           SSL_clear_options(s, 0xFFFFFFFFL);
72. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
73.   
74.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:3831:1: start of procedure SSL_CTX_get_options()
  3829.    * control interface.
  3830.    */
  3831. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  3832.   {
  3833.       return ctx->options;

ssl/ssl_lib.c:3833:5: 
  3831.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  3832.   {
  3833. >     return ctx->options;
  3834.   }
  3835.   unsigned long SSL_get_options(const SSL* s)

ssl/ssl_lib.c:3834:1: return from a call to SSL_CTX_get_options
  3832.   {
  3833.       return ctx->options;
  3834. > }
  3835.   unsigned long SSL_get_options(const SSL* s)
  3836.   {

ssl/ssl_lib.c:3843:1: start of procedure SSL_set_options()
  3841.       return ctx->options |= op;
  3842.   }
  3843. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  3844.   {
  3845.       return s->options |= op;

ssl/ssl_lib.c:3845:5: 
  3843.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  3844.   {
  3845. >     return s->options |= op;
  3846.   }
  3847.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

ssl/ssl_lib.c:3846:1: return from a call to SSL_set_options
  3844.   {
  3845.       return s->options |= op;
  3846. > }
  3847.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)
  3848.   {

test/handshake_helper.c:74:9: 
72.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
73.   
74. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
75.           return SSL_TLSEXT_ERR_OK;
76.       } else if (strcmp(servername, "server1") == 0) {
