ssl/statem/statem_lib.c:746: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 739, column 34 is not reachable after line 746, column 13.
Showing all 49 steps of the trace


ssl/statem/statem_lib.c:709:1: start of procedure ssl_add_cert_chain()
707.   
708.   /* Add certificate chain to provided WPACKET */
709. > static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk, int *al)
710.   {
711.       int i, chain_count;

ssl/statem/statem_lib.c:714:5: 
712.       X509 *x;
713.       STACK_OF(X509) *extra_certs;
714. >     STACK_OF(X509) *chain = NULL;
715.       X509_STORE *chain_store;
716.       int tmpal = SSL_AD_INTERNAL_ERROR;

ssl/statem/statem_lib.c:716:5: 
714.       STACK_OF(X509) *chain = NULL;
715.       X509_STORE *chain_store;
716. >     int tmpal = SSL_AD_INTERNAL_ERROR;
717.   
718.       if (cpk == NULL || cpk->x509 == NULL)

ssl/statem/statem_lib.c:718:9: Taking false branch
716.       int tmpal = SSL_AD_INTERNAL_ERROR;
717.   
718.       if (cpk == NULL || cpk->x509 == NULL)
               ^
719.           return 1;
720.   

ssl/statem/statem_lib.c:718:24: Taking false branch
716.       int tmpal = SSL_AD_INTERNAL_ERROR;
717.   
718.       if (cpk == NULL || cpk->x509 == NULL)
                              ^
719.           return 1;
720.   

ssl/statem/statem_lib.c:721:5: 
719.           return 1;
720.   
721. >     x = cpk->x509;
722.   
723.       /*

ssl/statem/statem_lib.c:726:9: Taking false branch
724.        * If we have a certificate specific chain use it, else use parent ctx.
725.        */
726.       if (cpk->chain != NULL)
               ^
727.           extra_certs = cpk->chain;
728.       else

ssl/statem/statem_lib.c:729:9: 
727.           extra_certs = cpk->chain;
728.       else
729. >         extra_certs = s->ctx->extra_certs;
730.   
731.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)

ssl/statem/statem_lib.c:731:10: Taking false branch
729.           extra_certs = s->ctx->extra_certs;
730.   
731.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
                ^
732.           chain_store = NULL;
733.       else if (s->cert->chain_store)

ssl/statem/statem_lib.c:731:47: Taking false branch
729.           extra_certs = s->ctx->extra_certs;
730.   
731.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
                                                     ^
732.           chain_store = NULL;
733.       else if (s->cert->chain_store)

ssl/statem/statem_lib.c:733:14: Taking false branch
731.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
732.           chain_store = NULL;
733.       else if (s->cert->chain_store)
                    ^
734.           chain_store = s->cert->chain_store;
735.       else

ssl/statem/statem_lib.c:736:9: 
734.           chain_store = s->cert->chain_store;
735.       else
736. >         chain_store = s->ctx->cert_store;
737.   
738.       if (chain_store != NULL) {

ssl/statem/statem_lib.c:738:9: Taking true branch
736.           chain_store = s->ctx->cert_store;
737.   
738.       if (chain_store != NULL) {
               ^
739.           X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
740.   

ssl/statem/statem_lib.c:739:9: 
737.   
738.       if (chain_store != NULL) {
739. >         X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
740.   
741.           if (xs_ctx == NULL) {

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)

ssl/statem/statem_lib.c:741:13: Taking false branch
739.           X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
740.   
741.           if (xs_ctx == NULL) {
                   ^
742.               SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, ERR_R_MALLOC_FAILURE);
743.               goto err;

ssl/statem/statem_lib.c:745:14: Taking true branch
743.               goto err;
744.           }
745.           if (!X509_STORE_CTX_init(xs_ctx, chain_store, x, NULL)) {
                    ^
746.               X509_STORE_CTX_free(xs_ctx);
747.               SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, ERR_R_X509_LIB);

ssl/statem/statem_lib.c:746:13: 
744.           }
745.           if (!X509_STORE_CTX_init(xs_ctx, chain_store, x, NULL)) {
746. >             X509_STORE_CTX_free(xs_ctx);
747.               SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, ERR_R_X509_LIB);
748.               goto err;

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,
