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


ssl/statem/statem_lib.c:889:1: start of procedure ssl_add_cert_chain()
887.   
888.   /* Add certificate chain to provided WPACKET */
889. > static int ssl_add_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk)
890.   {
891.       int i, chain_count;

ssl/statem/statem_lib.c:894:5: 
892.       X509 *x;
893.       STACK_OF(X509) *extra_certs;
894. >     STACK_OF(X509) *chain = NULL;
895.       X509_STORE *chain_store;
896.   

ssl/statem/statem_lib.c:897:9: Taking false branch
895.       X509_STORE *chain_store;
896.   
897.       if (cpk == NULL || cpk->x509 == NULL)
               ^
898.           return 1;
899.   

ssl/statem/statem_lib.c:897:24: Taking false branch
895.       X509_STORE *chain_store;
896.   
897.       if (cpk == NULL || cpk->x509 == NULL)
                              ^
898.           return 1;
899.   

ssl/statem/statem_lib.c:900:5: 
898.           return 1;
899.   
900. >     x = cpk->x509;
901.   
902.       /*

ssl/statem/statem_lib.c:905:9: Taking false branch
903.        * If we have a certificate specific chain use it, else use parent ctx.
904.        */
905.       if (cpk->chain != NULL)
               ^
906.           extra_certs = cpk->chain;
907.       else

ssl/statem/statem_lib.c:908:9: 
906.           extra_certs = cpk->chain;
907.       else
908. >         extra_certs = s->ctx->extra_certs;
909.   
910.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)

ssl/statem/statem_lib.c:910:10: Taking false branch
908.           extra_certs = s->ctx->extra_certs;
909.   
910.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
                ^
911.           chain_store = NULL;
912.       else if (s->cert->chain_store)

ssl/statem/statem_lib.c:910:47: Taking false branch
908.           extra_certs = s->ctx->extra_certs;
909.   
910.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
                                                     ^
911.           chain_store = NULL;
912.       else if (s->cert->chain_store)

ssl/statem/statem_lib.c:912:14: Taking false branch
910.       if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || extra_certs)
911.           chain_store = NULL;
912.       else if (s->cert->chain_store)
                    ^
913.           chain_store = s->cert->chain_store;
914.       else

ssl/statem/statem_lib.c:915:9: 
913.           chain_store = s->cert->chain_store;
914.       else
915. >         chain_store = s->ctx->cert_store;
916.   
917.       if (chain_store != NULL) {

ssl/statem/statem_lib.c:917:9: Taking true branch
915.           chain_store = s->ctx->cert_store;
916.   
917.       if (chain_store != NULL) {
               ^
918.           X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
919.   

ssl/statem/statem_lib.c:918:9: 
916.   
917.       if (chain_store != NULL) {
918. >         X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
919.   
920.           if (xs_ctx == NULL) {

crypto/x509/x509_vfy.c:2151:1: start of procedure X509_STORE_CTX_new()
  2149.   }
  2150.   
  2151. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2152.   {
  2153.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2153:5: 
  2151.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2152.   {
  2153. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2154.   
  2155.       if (ctx == NULL) {

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
    226.   }
    227.   
    228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230. >     void *ret = CRYPTO_malloc(num, file, line);
    231.   
    232.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
      190.   #endif
      191.   
      192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194.       void *ret = NULL;

crypto/mem.c:194:5: 
      192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194. >     void *ret = NULL;
      195.   
      196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
      195.   
      196.       INCREMENT(malloc_count);
      197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      198.           return malloc_impl(num, file, line);
      199.   

crypto/mem.c:200:9: Taking false branch
      198.           return malloc_impl(num, file, line);
      199.   
      200.       if (num == 0)
                     ^
      201.           return NULL;
      202.   

crypto/mem.c:204:9: Taking false branch
      202.   
      203.       FAILTEST();
      204.       if (allow_customize) {
                     ^
      205.           /*
      206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:221:5: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:221:19: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:222:5: 
      220.   #else
      221.       (void)(file); (void)(line);
      222. >     ret = malloc(num);
      223.   #endif
      224.   

crypto/mem.c:225:5: 
      223.   #endif
      224.   
      225. >     return ret;
      226.   }
      227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
      224.   
      225.       return ret;
      226. > }
      227.   
      228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
    231.   
    232.       FAILTEST();
    233.       if (ret != NULL)
                   ^
    234.           memset(ret, 0, num);
    235.       return ret;

crypto/mem.c:234:9: 
    232.       FAILTEST();
    233.       if (ret != NULL)
    234. >         memset(ret, 0, num);
    235.       return ret;
    236.   }

crypto/mem.c:235:5: 
    233.       if (ret != NULL)
    234.           memset(ret, 0, num);
    235. >     return ret;
    236.   }
    237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
    234.           memset(ret, 0, num);
    235.       return ret;
    236. > }
    237.   
    238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2155:9: Taking false branch
  2153.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2154.   
  2155.       if (ctx == NULL) {
                  ^
  2156.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2157.           return NULL;

crypto/x509/x509_vfy.c:2159:5: 
  2157.           return NULL;
  2158.       }
  2159. >     return ctx;
  2160.   }
  2161.   

crypto/x509/x509_vfy.c:2160:1: return from a call to X509_STORE_CTX_new
  2158.       }
  2159.       return ctx;
  2160. > }
  2161.   
  2162.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

ssl/statem/statem_lib.c:920:13: Taking false branch
918.           X509_STORE_CTX *xs_ctx = X509_STORE_CTX_new();
919.   
920.           if (xs_ctx == NULL) {
                   ^
921.               SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN,
922.                        ERR_R_MALLOC_FAILURE);

ssl/statem/statem_lib.c:925:14: Taking true branch
923.               return 0;
924.           }
925.           if (!X509_STORE_CTX_init(xs_ctx, chain_store, x, NULL)) {
                    ^
926.               X509_STORE_CTX_free(xs_ctx);
927.               SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN,

ssl/statem/statem_lib.c:926:13: 
924.           }
925.           if (!X509_STORE_CTX_init(xs_ctx, chain_store, x, NULL)) {
926. >             X509_STORE_CTX_free(xs_ctx);
927.               SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_ADD_CERT_CHAIN,
928.                        ERR_R_X509_LIB);

crypto/x509/x509_vfy.c:2162:1: start of procedure X509_STORE_CTX_free()
  2160.   }
  2161.   
  2162. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2163.   {
  2164.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2164:9: Taking false branch
  2162.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2163.   {
  2164.       if (ctx == NULL)
                  ^
  2165.           return;
  2166.   

crypto/x509/x509_vfy.c:2167:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2165.           return;
  2166.   
  2167.       X509_STORE_CTX_cleanup(ctx);
              ^
  2168.       OPENSSL_free(ctx);
  2169.   }

crypto/x509/x509_vfy.c:2168:5: 
  2166.   
  2167.       X509_STORE_CTX_cleanup(ctx);
  2168. >     OPENSSL_free(ctx);
  2169.   }
  2170.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2169:1: return from a call to X509_STORE_CTX_free
  2167.       X509_STORE_CTX_cleanup(ctx);
  2168.       OPENSSL_free(ctx);
  2169. > }
  2170.   
  2171.   int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
