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


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

test/handshake_helper.c:109:5: 
107.   static int select_server_ctx(SSL *s, void *arg, int ignore)
108.   {
109. >     const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
110.       HANDSHAKE_EX_DATA *ex_data =
111.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));

ssl/ssl_lib.c:2355:1: start of procedure SSL_get_servername()
  2353.    */
  2354.   
  2355. > const char *SSL_get_servername(const SSL *s, const int type)
  2356.   {
  2357.       if (type != TLSEXT_NAMETYPE_host_name)

ssl/ssl_lib.c:2357:9: Taking false branch
  2355.   const char *SSL_get_servername(const SSL *s, const int type)
  2356.   {
  2357.       if (type != TLSEXT_NAMETYPE_host_name)
                  ^
  2358.           return NULL;
  2359.   

ssl/ssl_lib.c:2360:12: Condition is true
  2358.           return NULL;
  2359.   
  2360.       return s->session && !s->ext.hostname ?
                     ^
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:27: Condition is true
  2358.           return NULL;
  2359.   
  2360.       return s->session && !s->ext.hostname ?
                                    ^
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:12: 
  2358.           return NULL;
  2359.   
  2360. >     return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2360:5: 
  2358.           return NULL;
  2359.   
  2360. >     return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362.   }

ssl/ssl_lib.c:2362:1: return from a call to SSL_get_servername
  2360.       return s->session && !s->ext.hostname ?
  2361.           s->session->ext.hostname : s->ext.hostname;
  2362. > }
  2363.   
  2364.   int SSL_get_servername_type(const SSL *s)

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

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: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: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:113:9: Taking false branch
111.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
112.   
113.       if (servername == NULL) {
               ^
114.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
115.           return SSL_TLSEXT_ERR_NOACK;

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

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

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

ssl/ssl_lib.c:3582:1: start of procedure SSL_set_SSL_CTX()
  3580.   }
  3581.   
  3582. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3583.   {
  3584.       CERT *new_cert;

ssl/ssl_lib.c:3585:9: Taking false branch
  3583.   {
  3584.       CERT *new_cert;
  3585.       if (ssl->ctx == ctx)
                  ^
  3586.           return ssl->ctx;
  3587.       if (ctx == NULL)

ssl/ssl_lib.c:3587:9: Taking false branch
  3585.       if (ssl->ctx == ctx)
  3586.           return ssl->ctx;
  3587.       if (ctx == NULL)
                  ^
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3589:5: Skipping ssl_cert_dup(): empty list of specs
  3587.       if (ctx == NULL)
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3590.       if (new_cert == NULL) {
  3591.           return NULL;

ssl/ssl_lib.c:3590:9: Taking false branch
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);
  3590.       if (new_cert == NULL) {
                  ^
  3591.           return NULL;
  3592.       }

ssl/ssl_lib.c:3594:10: Taking false branch
  3592.       }
  3593.   
  3594.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3595.           ssl_cert_free(new_cert);
  3596.           return NULL;

ssl/ssl_lib.c:3599:5: 
  3597.       }
  3598.   
  3599. >     ssl_cert_free(ssl->cert);
  3600.       ssl->cert = new_cert;
  3601.   

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

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

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

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

ssl/ssl_lib.c:3600:5: 
  3598.   
  3599.       ssl_cert_free(ssl->cert);
  3600. >     ssl->cert = new_cert;
  3601.   
  3602.       /*

ssl/ssl_lib.c:3606:10: Condition is false
  3604.        * so setter APIs must prevent invalid lengths from entering the system.
  3605.        */
  3606.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3607.           return NULL;
  3608.   

ssl/ssl_lib.c:3606:10: Taking true branch
  3604.        * so setter APIs must prevent invalid lengths from entering the system.
  3605.        */
  3606.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3607.           return NULL;
  3608.   

ssl/ssl_lib.c:3607:9: 
  3605.        */
  3606.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
  3607. >         return NULL;
  3608.   
  3609.       /*

ssl/ssl_lib.c:3627:1: return from a call to SSL_set_SSL_CTX
  3625.   
  3626.       return ssl->ctx;
  3627. > }
  3628.   
  3629.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

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

ssl/ssl_lib.c:4163:1: start of procedure SSL_clear_options()
  4161.   }
  4162.   
  4163. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4164.   {
  4165.       return s->options &= ~op;

ssl/ssl_lib.c:4165:5: 
  4163.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4164.   {
  4165. >     return s->options &= ~op;
  4166.   }
  4167.   

ssl/ssl_lib.c:4166:1: return from a call to SSL_clear_options
  4164.   {
  4165.       return s->options &= ~op;
  4166. > }
  4167.   
  4168.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

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

ssl/ssl_lib.c:4138:1: start of procedure SSL_CTX_get_options()
  4136.    * control interface.
  4137.    */
  4138. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4139.   {
  4140.       return ctx->options;

ssl/ssl_lib.c:4140:5: 
  4138.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4139.   {
  4140. >     return ctx->options;
  4141.   }
  4142.   

ssl/ssl_lib.c:4141:1: return from a call to SSL_CTX_get_options
  4139.   {
  4140.       return ctx->options;
  4141. > }
  4142.   
  4143.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4153:1: start of procedure SSL_set_options()
  4151.   }
  4152.   
  4153. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4154.   {
  4155.       return s->options |= op;

ssl/ssl_lib.c:4155:5: 
  4153.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4154.   {
  4155. >     return s->options |= op;
  4156.   }
  4157.   

ssl/ssl_lib.c:4156:1: return from a call to SSL_set_options
  4154.   {
  4155.       return s->options |= op;
  4156. > }
  4157.   
  4158.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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