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:3376:1: start of procedure SSL_get_SSL_CTX()
  3374.   }
  3375.   
  3376. > SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl)
  3377.   {
  3378.       return ssl->ctx;

ssl/ssl_lib.c:3378:5: 
  3376.   SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl)
  3377.   {
  3378. >     return ssl->ctx;
  3379.   }
  3380.   

ssl/ssl_lib.c:3379:1: return from a call to SSL_get_SSL_CTX
  3377.   {
  3378.       return ssl->ctx;
  3379. > }
  3380.   
  3381.   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:3549:1: start of procedure SSL_CTX_get_cert_store()
  3547.   }
  3548.   
  3549. > X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx)
  3550.   {
  3551.       return (ctx->cert_store);

ssl/ssl_lib.c:3551:5: 
  3549.   X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx)
  3550.   {
  3551. >     return (ctx->cert_store);
  3552.   }
  3553.   

ssl/ssl_lib.c:3552:1: return from a call to SSL_CTX_get_cert_store
  3550.   {
  3551.       return (ctx->cert_store);
  3552. > }
  3553.   
  3554.   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:63:1: start of procedure CRYPTO_THREAD_run_once()
    61.   }
    62.   
    63. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    64.   {
    65.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:65:9: Taking true branch
    63.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    64.   {
    65.       if (pthread_once(once, init) != 0)
                  ^
    66.           return 0;
    67.   

crypto/threads_pthread.c:66:9: 
    64.   {
    65.       if (pthread_once(once, init) != 0)
    66. >         return 0;
    67.   
    68.       return 1;

crypto/threads_pthread.c:69:1: return from a call to CRYPTO_THREAD_run_once
    67.   
    68.       return 1;
    69. > }
    70.   
    71.   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:98:1: start of procedure sk_X509_value()
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:265:1: start of procedure OPENSSL_sk_value()
    263.   }
    264.   
    265. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    266.   {
    267.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:267:9: Taking true branch
    265.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    266.   {
    267.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    268.           return NULL;
    269.       return (void *)st->data[i];

crypto/stack/stack.c:268:9: 
    266.   {
    267.       if (st == NULL || i < 0 || i >= st->num)
    268. >         return NULL;
    269.       return (void *)st->data[i];
    270.   }

crypto/stack/stack.c:270:1: return from a call to OPENSSL_sk_value
    268.           return NULL;
    269.       return (void *)st->data[i];
    270. > }
    271.   
    272.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509.h:98:1: return from a call to sk_X509_value
  96.   typedef struct x509_cinf_st X509_CINF;
  97.   
  98. > DEFINE_STACK_OF(X509)
  99.   
  100.   /* 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:2200:1: start of procedure X509_STORE_CTX_new()
  2198.   }
  2199.   
  2200. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2201.   {
  2202.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

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

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

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

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

crypto/x509/x509_vfy.c:2209:1: return from a call to X509_STORE_CTX_new
  2207.       }
  2208.       return ctx;
  2209. > }
  2210.   
  2211.   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:2211:1: start of procedure X509_STORE_CTX_free()
  2209.   }
  2210.   
  2211. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2212.   {
  2213.       if (ctx == NULL)

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

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

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

crypto/mem.c:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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