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


apps/pkcs12.c:759:1: start of procedure get_cert_chain()
757.   /* Given a single certificate return a verified chain or NULL if error */
758.   
759. > static int get_cert_chain(X509 *cert, X509_STORE *store,
760.                             STACK_OF(X509) **chain)
761.   {

apps/pkcs12.c:762:5: 
760.                             STACK_OF(X509) **chain)
761.   {
762. >     X509_STORE_CTX *store_ctx = NULL;
763.       STACK_OF(X509) *chn = NULL;
764.       int i = 0;

apps/pkcs12.c:763:5: 
761.   {
762.       X509_STORE_CTX *store_ctx = NULL;
763. >     STACK_OF(X509) *chn = NULL;
764.       int i = 0;
765.   

apps/pkcs12.c:764:5: 
762.       X509_STORE_CTX *store_ctx = NULL;
763.       STACK_OF(X509) *chn = NULL;
764. >     int i = 0;
765.   
766.       store_ctx = X509_STORE_CTX_new();

apps/pkcs12.c:766:5: 
764.       int i = 0;
765.   
766. >     store_ctx = X509_STORE_CTX_new();
767.       if (store_ctx == NULL) {
768.           i =  X509_V_ERR_UNSPECIFIED;

crypto/x509/x509_vfy.c:2125:1: start of procedure X509_STORE_CTX_new()
  2123.   }
  2124.   
  2125. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2126.   {
  2127.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2127:5: 
  2125.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2126.   {
  2127. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2128.   
  2129.       if (ctx == NULL) {

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:151:9: 
    149.   
    150.       if (ret != NULL)
    151. >         memset(ret, 0, num);
    152.       return ret;
    153.   }

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2129:9: Taking false branch
  2127.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2128.   
  2129.       if (ctx == NULL) {
                  ^
  2130.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2131.           return NULL;

crypto/x509/x509_vfy.c:2133:5: 
  2131.           return NULL;
  2132.       }
  2133. >     return ctx;
  2134.   }
  2135.   

crypto/x509/x509_vfy.c:2134:1: return from a call to X509_STORE_CTX_new
  2132.       }
  2133.       return ctx;
  2134. > }
  2135.   
  2136.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

apps/pkcs12.c:767:9: Taking false branch
765.   
766.       store_ctx = X509_STORE_CTX_new();
767.       if (store_ctx == NULL) {
               ^
768.           i =  X509_V_ERR_UNSPECIFIED;
769.           goto end;

apps/pkcs12.c:771:10: Taking true branch
769.           goto end;
770.       }
771.       if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {
                ^
772.           i =  X509_V_ERR_UNSPECIFIED;
773.           goto end;

apps/pkcs12.c:772:9: 
770.       }
771.       if (!X509_STORE_CTX_init(store_ctx, store, cert, NULL)) {
772. >         i =  X509_V_ERR_UNSPECIFIED;
773.           goto end;
774.       }

apps/pkcs12.c:782:1: 
780.           i = X509_V_ERR_UNSPECIFIED;
781.   
782. > end:
783.       X509_STORE_CTX_free(store_ctx);
784.       *chain = chn;

apps/pkcs12.c:783:5: 
781.   
782.   end:
783. >     X509_STORE_CTX_free(store_ctx);
784.       *chain = chn;
785.       return i;

crypto/x509/x509_vfy.c:2136:1: start of procedure X509_STORE_CTX_free()
  2134.   }
  2135.   
  2136. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2137.   {
  2138.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2138:9: Taking false branch
  2136.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2137.   {
  2138.       if (ctx == NULL)
                  ^
  2139.           return;
  2140.   

crypto/x509/x509_vfy.c:2141:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2139.           return;
  2140.   
  2141.       X509_STORE_CTX_cleanup(ctx);
              ^
  2142.       OPENSSL_free(ctx);
  2143.   }

crypto/x509/x509_vfy.c:2142:5: 
  2140.   
  2141.       X509_STORE_CTX_cleanup(ctx);
  2142. >     OPENSSL_free(ctx);
  2143.   }
  2144.   

crypto/mem.c:211:1: start of procedure CRYPTO_free()
    209.   }
    210.   
    211. > void CRYPTO_free(void *str, const char *file, int line)
    212.   {
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:213:9: Taking true branch
    211.   void CRYPTO_free(void *str, const char *file, int line)
    212.   {
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    214.           free_impl(str, file, line);
    215.           return;

crypto/mem.c:213:30: Taking true branch
    211.   void CRYPTO_free(void *str, const char *file, int line)
    212.   {
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    214.           free_impl(str, file, line);
    215.           return;

crypto/mem.c:214:9: Skipping __function_pointer__(): unresolved function pointer
    212.   {
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    214.           free_impl(str, file, line);
                   ^
    215.           return;
    216.       }

crypto/mem.c:215:9: 
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    214.           free_impl(str, file, line);
    215. >         return;
    216.       }
    217.   

crypto/mem.c:229:1: return from a call to CRYPTO_free
    227.       free(str);
    228.   #endif
    229. > }
    230.   
    231.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2143:1: return from a call to X509_STORE_CTX_free
  2141.       X509_STORE_CTX_cleanup(ctx);
  2142.       OPENSSL_free(ctx);
  2143. > }
  2144.   
  2145.   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    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    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}']