test/crltest.c:277: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 244, column 27 is not reachable after line 277, column 5.
Showing all 70 steps of the trace


test/crltest.c:241:1: start of procedure verify()
239.    * Returns a value from X509_V_ERR_xxx or X509_V_OK.
240.    */
241. > static int verify(X509 *leaf, X509 *root, STACK_OF(X509_CRL) *crls,
242.                     unsigned long flags)
243.   {

test/crltest.c:244:5: 
242.                     unsigned long flags)
243.   {
244. >     X509_STORE_CTX *ctx = X509_STORE_CTX_new();
245.       X509_STORE *store = X509_STORE_new();
246.       X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();

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:198:1: start of procedure CRYPTO_zalloc()
    196.   }
    197.   
    198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    199.   {
    200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
    198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    199.   {
    200. >     void *ret = CRYPTO_malloc(num, file, line);
    201.   
    202.       FAILTEST();

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
      168.   #endif
      169.   
      170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      171.   {
      172.       void *ret = NULL;

crypto/mem.c:172:5: 
      170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      171.   {
      172. >     void *ret = NULL;
      173.   
      174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
      172.       void *ret = NULL;
      173.   
      174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      175.           return malloc_impl(num, file, line);
      176.   

crypto/mem.c:177:9: Taking false branch
      175.           return malloc_impl(num, file, line);
      176.   
      177.       if (num == 0)
                     ^
      178.           return NULL;
      179.   

crypto/mem.c:181:5: 
      179.   
      180.       FAILTEST();
      181. >     allow_customize = 0;
      182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
      189.       }
      190.   #else
      191. >     (void)(file); (void)(line);
      192.       ret = malloc(num);
      193.   #endif

crypto/mem.c:191:19: 
      189.       }
      190.   #else
      191. >     (void)(file); (void)(line);
      192.       ret = malloc(num);
      193.   #endif

crypto/mem.c:192:5: 
      190.   #else
      191.       (void)(file); (void)(line);
      192. >     ret = malloc(num);
      193.   #endif
      194.   

crypto/mem.c:195:5: 
      193.   #endif
      194.   
      195. >     return ret;
      196.   }
      197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
      194.   
      195.       return ret;
      196. > }
      197.   
      198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
    201.   
    202.       FAILTEST();
    203.       if (ret != NULL)
                   ^
    204.           memset(ret, 0, num);
    205.       return ret;

crypto/mem.c:204:9: 
    202.       FAILTEST();
    203.       if (ret != NULL)
    204. >         memset(ret, 0, num);
    205.       return ret;
    206.   }

crypto/mem.c:205:5: 
    203.       if (ret != NULL)
    204.           memset(ret, 0, num);
    205. >     return ret;
    206.   }
    207.   

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
    204.           memset(ret, 0, num);
    205.       return ret;
    206. > }
    207.   
    208.   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)

test/crltest.c:245:5: Skipping X509_STORE_new(): empty list of specs
243.   {
244.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
245.       X509_STORE *store = X509_STORE_new();
           ^
246.       X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
247.       STACK_OF(X509) *roots = sk_X509_new_null();

test/crltest.c:246:5: Skipping X509_VERIFY_PARAM_new(): empty list of specs
244.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
245.       X509_STORE *store = X509_STORE_new();
246.       X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
           ^
247.       STACK_OF(X509) *roots = sk_X509_new_null();
248.       int status = X509_V_ERR_UNSPECIFIED;

test/crltest.c:247:5: 
245.       X509_STORE *store = X509_STORE_new();
246.       X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
247. >     STACK_OF(X509) *roots = sk_X509_new_null();
248.       int status = X509_V_ERR_UNSPECIFIED;
249.   

include/openssl/x509.h:99:1: start of procedure sk_X509_new_null()
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:104:1: start of procedure OPENSSL_sk_new_null()
    102.   }
    103.   
    104. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
    105.   {
    106.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);

crypto/stack/stack.c:106:5: Skipping OPENSSL_sk_new(): empty list of specs
    104.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
    105.   {
    106.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);
               ^
    107.   }
    108.   

crypto/stack/stack.c:107:1: return from a call to OPENSSL_sk_new_null
    105.   {
    106.       return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);
    107. > }
    108.   
    109.   OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c)

include/openssl/x509.h:99:1: return from a call to sk_X509_new_null
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

test/crltest.c:248:5: 
246.       X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
247.       STACK_OF(X509) *roots = sk_X509_new_null();
248. >     int status = X509_V_ERR_UNSPECIFIED;
249.   
250.       if (!TEST_ptr(ctx)

test/crltest.c:250:10: 
248.       int status = X509_V_ERR_UNSPECIFIED;
249.   
250. >     if (!TEST_ptr(ctx)
251.           || !TEST_ptr(store)
252.           || !TEST_ptr(param)

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/crltest.c:250:10: Taking false branch
248.       int status = X509_V_ERR_UNSPECIFIED;
249.   
250.       if (!TEST_ptr(ctx)
                ^
251.           || !TEST_ptr(store)
252.           || !TEST_ptr(param)

test/crltest.c:251:13: 
249.   
250.       if (!TEST_ptr(ctx)
251. >         || !TEST_ptr(store)
252.           || !TEST_ptr(param)
253.           || !TEST_ptr(roots))

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/crltest.c:251:13: Taking false branch
249.   
250.       if (!TEST_ptr(ctx)
251.           || !TEST_ptr(store)
                   ^
252.           || !TEST_ptr(param)
253.           || !TEST_ptr(roots))

test/crltest.c:252:13: 
250.       if (!TEST_ptr(ctx)
251.           || !TEST_ptr(store)
252. >         || !TEST_ptr(param)
253.           || !TEST_ptr(roots))
254.           goto err;

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking false branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:5: Skipping test_fail_message(): empty list of specs
  229.       if (p != NULL)
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
             ^
  232.       return 0;
  233.   }

test/testutil/tests.c:232:5: 
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232. >     return 0;
  233.   }
  234.   

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/crltest.c:252:13: Taking true branch
250.       if (!TEST_ptr(ctx)
251.           || !TEST_ptr(store)
252.           || !TEST_ptr(param)
                   ^
253.           || !TEST_ptr(roots))
254.           goto err;

test/crltest.c:274:1: 
272.       status = X509_verify_cert(ctx) == 1 ? X509_V_OK
273.                                           : X509_STORE_CTX_get_error(ctx);
274. > err:
275.       sk_X509_pop_free(roots, X509_free);
276.       sk_X509_CRL_pop_free(crls, X509_CRL_free);

test/crltest.c:275:5: 
273.                                           : X509_STORE_CTX_get_error(ctx);
274.   err:
275. >     sk_X509_pop_free(roots, X509_free);
276.       sk_X509_CRL_pop_free(crls, X509_CRL_free);
277.       X509_STORE_CTX_free(ctx);

include/openssl/x509.h:99:1: start of procedure sk_X509_pop_free()
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

include/openssl/x509.h:99:1: return from a call to sk_X509_pop_free
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

test/crltest.c:276:5: 
274.   err:
275.       sk_X509_pop_free(roots, X509_free);
276. >     sk_X509_CRL_pop_free(crls, X509_CRL_free);
277.       X509_STORE_CTX_free(ctx);
278.       X509_STORE_free(store);

include/openssl/x509.h:228:1: start of procedure sk_X509_CRL_pop_free()
  226.   typedef struct X509_crl_info_st X509_CRL_INFO;
  227.   
  228. > DEFINE_STACK_OF(X509_CRL)
  229.   
  230.   typedef struct private_key_st {

include/openssl/x509.h:228:1: return from a call to sk_X509_CRL_pop_free
  226.   typedef struct X509_crl_info_st X509_CRL_INFO;
  227.   
  228. > DEFINE_STACK_OF(X509_CRL)
  229.   
  230.   typedef struct private_key_st {

test/crltest.c:277:5: 
275.       sk_X509_pop_free(roots, X509_free);
276.       sk_X509_CRL_pop_free(crls, X509_CRL_free);
277. >     X509_STORE_CTX_free(ctx);
278.       X509_STORE_free(store);
279.       return status;

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:265:1: start of procedure CRYPTO_free()
    263.   }
    264.   
    265. > void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:267:9: Taking true branch
    265.   void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    268.           free_impl(str, file, line);
    269.           return;

crypto/mem.c:267:30: Taking true branch
    265.   void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    268.           free_impl(str, file, line);
    269.           return;

crypto/mem.c:268:9: Skipping __function_pointer__(): unresolved function pointer
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    268.           free_impl(str, file, line);
                   ^
    269.           return;
    270.       }

crypto/mem.c:269:9: 
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    268.           free_impl(str, file, line);
    269. >         return;
    270.       }
    271.   

crypto/mem.c:283:1: return from a call to CRYPTO_free
    281.       free(str);
    282.   #endif
    283. > }
    284.   
    285.   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,

static int verify(X509 *leaf, X509 *root, STACK_OF(X509_CRL) *crls,
                  unsigned long flags)
{
    X509_STORE_CTX *ctx = X509_STORE_CTX_new();
    X509_STORE *store = X509_STORE_new();
    X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
    STACK_OF(X509) *roots = sk_X509_new_null();
    int status = X509_V_ERR_UNSPECIFIED;
    if (!TEST_ptr(ctx)
        || !TEST_ptr(store)
        || !TEST_ptr(param)
        || !TEST_ptr(roots))
        goto err;
    X509_up_ref(root);
    if (!TEST_true(sk_X509_push(roots, root))
        || !TEST_true(X509_STORE_CTX_init(ctx, store, leaf, NULL)))
        goto err;
    X509_STORE_CTX_set0_trusted_stack(ctx, roots);
    X509_STORE_CTX_set0_crls(ctx, crls);
    X509_VERIFY_PARAM_set_time(param, PARAM_TIME);
    if (!TEST_long_eq(X509_VERIFY_PARAM_get_time(param), PARAM_TIME))
        goto err;
    X509_VERIFY_PARAM_set_depth(param, 16);
    if (flags)
        X509_VERIFY_PARAM_set_flags(param, flags);
    X509_STORE_CTX_set0_param(ctx, param);
    ERR_clear_error();
    status = X509_verify_cert(ctx) == 1 ? X509_V_OK
                                        : X509_STORE_CTX_get_error(ctx);
err:
    sk_X509_pop_free(roots, X509_free);
    sk_X509_CRL_pop_free(crls, X509_CRL_free);
    X509_STORE_CTX_free(ctx);
    X509_STORE_free(store);
    return status;
}
['static int verify(X509 *leaf, X509 *root, STACK_OF(X509_CRL) *crls,\n                  unsigned long flags)\n{\n    X509_STORE_CTX *ctx = X509_STORE_CTX_new();\n    X509_STORE *store = X509_STORE_new();\n    X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();\n    STACK_OF(X509) *roots = sk_X509_new_null();\n    int status = X509_V_ERR_UNSPECIFIED;\n    if (!TEST_ptr(ctx)\n        || !TEST_ptr(store)\n        || !TEST_ptr(param)\n        || !TEST_ptr(roots))\n        goto err;\n    X509_up_ref(root);\n    if (!TEST_true(sk_X509_push(roots, root))\n        || !TEST_true(X509_STORE_CTX_init(ctx, store, leaf, NULL)))\n        goto err;\n    X509_STORE_CTX_set0_trusted_stack(ctx, roots);\n    X509_STORE_CTX_set0_crls(ctx, crls);\n    X509_VERIFY_PARAM_set_time(param, PARAM_TIME);\n    if (!TEST_long_eq(X509_VERIFY_PARAM_get_time(param), PARAM_TIME))\n        goto err;\n    X509_VERIFY_PARAM_set_depth(param, 16);\n    if (flags)\n        X509_VERIFY_PARAM_set_flags(param, flags);\n    X509_STORE_CTX_set0_param(ctx, param);\n    ERR_clear_error();\n    status = X509_verify_cert(ctx) == 1 ? X509_V_OK\n                                        : X509_STORE_CTX_get_error(ctx);\nerr:\n    sk_X509_pop_free(roots, X509_free);\n    sk_X509_CRL_pop_free(crls, X509_CRL_free);\n    X509_STORE_CTX_free(ctx);\n    X509_STORE_free(store);\n    return status;\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'DEFINE_STACK_OF(X509)', 'OPENSSL_STACK *OPENSSL_sk_new_null(void)\n{\n    return OPENSSL_sk_new((OPENSSL_sk_compfunc)NULL);\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'DEFINE_STACK_OF(X509_CRL)', '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}']