test/danetest.c:106: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 84, column 22 is not reachable after line 106, column 5.
Showing all 65 steps of the trace


test/danetest.c:75:1: start of procedure verify_chain()
73.   }
74.   
75. > static int verify_chain(SSL *ssl, STACK_OF(X509) *chain)
76.   {
77.       int ret = -1;

test/danetest.c:77:5: 
75.   static int verify_chain(SSL *ssl, STACK_OF(X509) *chain)
76.   {
77. >     int ret = -1;
78.       X509_STORE_CTX *store_ctx;
79.       SSL_CTX *ssl_ctx = SSL_get_SSL_CTX(ssl);

test/danetest.c:79:5: 
77.       int ret = -1;
78.       X509_STORE_CTX *store_ctx;
79. >     SSL_CTX *ssl_ctx = SSL_get_SSL_CTX(ssl);
80.       X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
81.       int store_ctx_idx = SSL_get_ex_data_X509_STORE_CTX_idx();

ssl/ssl_lib.c:3478:1: start of procedure SSL_get_SSL_CTX()
  3476.   }
  3477.   
  3478. > SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl)
  3479.   {
  3480.       return ssl->ctx;

ssl/ssl_lib.c:3480:5: 
  3478.   SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl)
  3479.   {
  3480. >     return ssl->ctx;
  3481.   }
  3482.   

ssl/ssl_lib.c:3481:1: return from a call to SSL_get_SSL_CTX
  3479.   {
  3480.       return ssl->ctx;
  3481. > }
  3482.   
  3483.   SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)

test/danetest.c:80:5: 
78.       X509_STORE_CTX *store_ctx;
79.       SSL_CTX *ssl_ctx = SSL_get_SSL_CTX(ssl);
80. >     X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
81.       int store_ctx_idx = SSL_get_ex_data_X509_STORE_CTX_idx();
82.       X509 *cert = sk_X509_value(chain, 0);

ssl/ssl_lib.c:3647:1: start of procedure SSL_CTX_get_cert_store()
  3645.   }
  3646.   
  3647. > X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx)
  3648.   {
  3649.       return (ctx->cert_store);

ssl/ssl_lib.c:3649:5: 
  3647.   X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx)
  3648.   {
  3649. >     return (ctx->cert_store);
  3650.   }
  3651.   

ssl/ssl_lib.c:3650:1: return from a call to SSL_CTX_get_cert_store
  3648.   {
  3649.       return (ctx->cert_store);
  3650. > }
  3651.   
  3652.   void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store)

test/danetest.c:81:5: 
79.       SSL_CTX *ssl_ctx = SSL_get_SSL_CTX(ssl);
80.       X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
81. >     int store_ctx_idx = SSL_get_ex_data_X509_STORE_CTX_idx();
82.       X509 *cert = sk_X509_value(chain, 0);
83.   

ssl/ssl_cert.c:49:1: start of procedure SSL_get_ex_data_X509_STORE_CTX_idx()
  47.   }
  48.   
  49. > int SSL_get_ex_data_X509_STORE_CTX_idx(void)
  50.   {
  51.   

ssl/ssl_cert.c:52:10: 
  50.   {
  51.   
  52. >     if (!RUN_ONCE(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init))
  53.           return -1;
  54.       return ssl_x509_store_ctx_idx;

crypto/threads_pthread.c:104:1: start of procedure CRYPTO_THREAD_run_once()
    102.   }
    103.   
    104. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    105.   {
    106.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:106:9: Taking true branch
    104.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    105.   {
    106.       if (pthread_once(once, init) != 0)
                   ^
    107.           return 0;
    108.   

crypto/threads_pthread.c:107:9: 
    105.   {
    106.       if (pthread_once(once, init) != 0)
    107. >         return 0;
    108.   
    109.       return 1;

crypto/threads_pthread.c:110:1: return from a call to CRYPTO_THREAD_run_once
    108.   
    109.       return 1;
    110. > }
    111.   
    112.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

ssl/ssl_cert.c:52:10: Condition is false
  50.   {
  51.   
  52.       if (!RUN_ONCE(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init))
                 ^
  53.           return -1;
  54.       return ssl_x509_store_ctx_idx;

ssl/ssl_cert.c:52:10: Taking true branch
  50.   {
  51.   
  52.       if (!RUN_ONCE(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init))
                 ^
  53.           return -1;
  54.       return ssl_x509_store_ctx_idx;

ssl/ssl_cert.c:53:9: 
  51.   
  52.       if (!RUN_ONCE(&ssl_x509_store_ctx_once, ssl_x509_store_ctx_init))
  53. >         return -1;
  54.       return ssl_x509_store_ctx_idx;
  55.   }

ssl/ssl_cert.c:55:1: return from a call to SSL_get_ex_data_X509_STORE_CTX_idx
  53.           return -1;
  54.       return ssl_x509_store_ctx_idx;
  55. > }
  56.   
  57.   CERT *ssl_cert_new(void)

test/danetest.c:82:5: 
80.       X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
81.       int store_ctx_idx = SSL_get_ex_data_X509_STORE_CTX_idx();
82. >     X509 *cert = sk_X509_value(chain, 0);
83.   
84.       if ((store_ctx = X509_STORE_CTX_new()) == NULL)

include/openssl/x509.h:97:1: start of procedure sk_X509_value()
  95.   typedef struct x509_cinf_st X509_CINF;
  96.   
  97. > DEFINE_STACK_OF(X509)
  98.   
  99.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:284:1: start of procedure OPENSSL_sk_value()
    282.   }
    283.   
    284. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:286:9: Taking true branch
    284.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    287.           return NULL;
    288.       return (void *)st->data[i];

crypto/stack/stack.c:287:9: 
    285.   {
    286.       if (st == NULL || i < 0 || i >= st->num)
    287. >         return NULL;
    288.       return (void *)st->data[i];
    289.   }

crypto/stack/stack.c:289:1: return from a call to OPENSSL_sk_value
    287.           return NULL;
    288.       return (void *)st->data[i];
    289. > }
    290.   
    291.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509.h:97:1: return from a call to sk_X509_value
  95.   typedef struct x509_cinf_st X509_CINF;
  96.   
  97. > DEFINE_STACK_OF(X509)
  98.   
  99.   /* This is used for a table of trust checking functions */

test/danetest.c:84:9: 
82.       X509 *cert = sk_X509_value(chain, 0);
83.   
84. >     if ((store_ctx = X509_STORE_CTX_new()) == NULL)
85.           return -1;
86.   

crypto/x509/x509_vfy.c:2201:1: start of procedure X509_STORE_CTX_new()
  2199.   }
  2200.   
  2201. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2202.   {
  2203.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2203:5: 
  2201.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2202.   {
  2203. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2204.   
  2205.       if (ctx == NULL) {

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
      156.   #endif
      157.   
      158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160.       void *ret = NULL;

crypto/mem.c:160:5: 
      158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160. >     void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
      160.       void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      163.           return malloc_impl(num, file, line);
      164.   

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num <= 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2205:9: Taking false branch
  2203.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2204.   
  2205.       if (ctx == NULL) {
                  ^
  2206.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2207.           return NULL;

crypto/x509/x509_vfy.c:2209:5: 
  2207.           return NULL;
  2208.       }
  2209. >     return ctx;
  2210.   }
  2211.   

crypto/x509/x509_vfy.c:2210:1: return from a call to X509_STORE_CTX_new
  2208.       }
  2209.       return ctx;
  2210. > }
  2211.   
  2212.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

test/danetest.c:84:9: Taking false branch
82.       X509 *cert = sk_X509_value(chain, 0);
83.   
84.       if ((store_ctx = X509_STORE_CTX_new()) == NULL)
              ^
85.           return -1;
86.   

test/danetest.c:87:10: Taking true branch
85.           return -1;
86.   
87.       if (!X509_STORE_CTX_init(store_ctx, store, cert, chain))
               ^
88.           goto end;
89.       if (!X509_STORE_CTX_set_ex_data(store_ctx, store_ctx_idx, ssl))

test/danetest.c:105:1: 
103.       SSL_set_verify_result(ssl, X509_STORE_CTX_get_error(store_ctx));
104.       X509_STORE_CTX_cleanup(store_ctx);
105. > end:
106.       X509_STORE_CTX_free(store_ctx);
107.   

test/danetest.c:106:5: 
104.       X509_STORE_CTX_cleanup(store_ctx);
105.   end:
106. >     X509_STORE_CTX_free(store_ctx);
107.   
108.       return (ret);

crypto/x509/x509_vfy.c:2212:1: start of procedure X509_STORE_CTX_free()
  2210.   }
  2211.   
  2212. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2213.   {
  2214.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2214:9: Taking false branch
  2212.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2213.   {
  2214.       if (ctx == NULL)
                  ^
  2215.           return;
  2216.   

crypto/x509/x509_vfy.c:2217:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2215.           return;
  2216.   
  2217.       X509_STORE_CTX_cleanup(ctx);
              ^
  2218.       OPENSSL_free(ctx);
  2219.   }

crypto/x509/x509_vfy.c:2218:5: 
  2216.   
  2217.       X509_STORE_CTX_cleanup(ctx);
  2218. >     OPENSSL_free(ctx);
  2219.   }
  2220.   

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2219:1: return from a call to X509_STORE_CTX_free
  2217.       X509_STORE_CTX_cleanup(ctx);
  2218.       OPENSSL_free(ctx);
  2219. > }
  2220.   
  2221.   int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
