apps/pkcs12.c:760: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 743, column 17 is not reachable after line 760, column 5.
Showing all 42 steps of the trace


apps/pkcs12.c:736:1: start of procedure get_cert_chain()
734.   /* Given a single certificate return a verified chain or NULL if error */
735.   
736. > static int get_cert_chain(X509 *cert, X509_STORE *store,
737.                             STACK_OF(X509) **chain)
738.   {

apps/pkcs12.c:739:5: 
737.                             STACK_OF(X509) **chain)
738.   {
739. >     X509_STORE_CTX *store_ctx = NULL;
740.       STACK_OF(X509) *chn = NULL;
741.       int i = 0;

apps/pkcs12.c:740:5: 
738.   {
739.       X509_STORE_CTX *store_ctx = NULL;
740. >     STACK_OF(X509) *chn = NULL;
741.       int i = 0;
742.   

apps/pkcs12.c:741:5: 
739.       X509_STORE_CTX *store_ctx = NULL;
740.       STACK_OF(X509) *chn = NULL;
741. >     int i = 0;
742.   
743.       store_ctx = X509_STORE_CTX_new();

apps/pkcs12.c:743:5: 
741.       int i = 0;
742.   
743. >     store_ctx = X509_STORE_CTX_new();
744.       if (store_ctx == NULL) {
745.           i =  X509_V_ERR_UNSPECIFIED;

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)

apps/pkcs12.c:744:9: Taking false branch
742.   
743.       store_ctx = X509_STORE_CTX_new();
744.       if (store_ctx == NULL) {
               ^
745.           i =  X509_V_ERR_UNSPECIFIED;
746.           goto end;

apps/pkcs12.c:748:10: Taking true branch
746.           goto end;
747.       }
748.       if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {
                ^
749.           i =  X509_V_ERR_UNSPECIFIED;
750.           goto end;

apps/pkcs12.c:749:9: 
747.       }
748.       if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {
749. >         i =  X509_V_ERR_UNSPECIFIED;
750.           goto end;
751.       }

apps/pkcs12.c:759:1: 
757.           i = X509_V_ERR_UNSPECIFIED;
758.   
759. > end:
760.       X509_STORE_CTX_free(store_ctx);
761.       *chain = chn;

apps/pkcs12.c:760:5: 
758.   
759.   end:
760. >     X509_STORE_CTX_free(store_ctx);
761.       *chain = chn;
762.       return i;

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,

static int get_cert_chain(X509 *cert, X509_STORE *store,
                          STACK_OF(X509) **chain)
{
    X509_STORE_CTX *store_ctx = NULL;
    STACK_OF(X509) *chn = NULL;
    int i = 0;
    store_ctx = X509_STORE_CTX_new();
    if (store_ctx == NULL) {
        i =  X509_V_ERR_UNSPECIFIED;
        goto end;
    }
    if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {
        i =  X509_V_ERR_UNSPECIFIED;
        goto end;
    }
    if (X509_verify_cert(store_ctx) > 0)
        chn = X509_STORE_CTX_get1_chain(store_ctx);
    else if ((i = X509_STORE_CTX_get_error(store_ctx)) == 0)
        i = X509_V_ERR_UNSPECIFIED;
end:
    X509_STORE_CTX_free(store_ctx);
    *chain = chn;
    return i;
}
['static int get_cert_chain(X509 *cert, X509_STORE *store,\n                          STACK_OF(X509) **chain)\n{\n    X509_STORE_CTX *store_ctx = NULL;\n    STACK_OF(X509) *chn = NULL;\n    int i = 0;\n    store_ctx = X509_STORE_CTX_new();\n    if (store_ctx == NULL) {\n        i =  X509_V_ERR_UNSPECIFIED;\n        goto end;\n    }\n    if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {\n        i =  X509_V_ERR_UNSPECIFIED;\n        goto end;\n    }\n    if (X509_verify_cert(store_ctx) > 0)\n        chn = X509_STORE_CTX_get1_chain(store_ctx);\n    else if ((i = X509_STORE_CTX_get_error(store_ctx)) == 0)\n        i = X509_V_ERR_UNSPECIFIED;\nend:\n    X509_STORE_CTX_free(store_ctx);\n    *chain = chn;\n    return i;\n}', 'X509_STORE_CTX *X509_STORE_CTX_new(void)\n{\n    X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL) {\n        X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return ctx;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num <= 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void X509_STORE_CTX_free(X509_STORE_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    X509_STORE_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']