crypto/ts/ts_verify_ctx.c:144: error: MEMORY_LEAK
  memory dynamically allocated by call to `TS_VERIFY_CTX_new()` at line 112, column 21 is not reachable after line 144, column 9.
Showing all 45 steps of the trace


crypto/ts/ts_verify_ctx.c:100:1: start of procedure TS_REQ_to_TS_VERIFY_CTX()
98.   }
99.   
100. > TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
101.   {
102.       TS_VERIFY_CTX *ret = ctx;

crypto/ts/ts_verify_ctx.c:102:5: 
100.   TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
101.   {
102. >     TS_VERIFY_CTX *ret = ctx;
103.       ASN1_OBJECT *policy;
104.       TS_MSG_IMPRINT *imprint;

crypto/ts/ts_verify_ctx.c:109:5: Condition is true
107.       const ASN1_INTEGER *nonce;
108.   
109.       OPENSSL_assert(req != NULL);
           ^
110.       if (ret)
111.           TS_VERIFY_CTX_cleanup(ret);

crypto/ts/ts_verify_ctx.c:110:9: Taking false branch
108.   
109.       OPENSSL_assert(req != NULL);
110.       if (ret)
               ^
111.           TS_VERIFY_CTX_cleanup(ret);
112.       else if ((ret = TS_VERIFY_CTX_new()) == NULL)

crypto/ts/ts_verify_ctx.c:112:14: 
110.       if (ret)
111.           TS_VERIFY_CTX_cleanup(ret);
112. >     else if ((ret = TS_VERIFY_CTX_new()) == NULL)
113.           return NULL;
114.   

crypto/ts/ts_verify_ctx.c:15:1: start of procedure TS_VERIFY_CTX_new()
  13.   #include "ts_lcl.h"
  14.   
  15. > TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
  16.   {
  17.       TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/ts/ts_verify_ctx.c:17:5: 
  15.   TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
  16.   {
  17. >     TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  18.   
  19.       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 true branch
      202.   
      203.       FAILTEST();
      204.       if (allow_customize) {
                     ^
      205.           /*
      206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
      208.            * allocation.
      209.            */
      210. >         allow_customize = 0;
      211.       }
      212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

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/ts/ts_verify_ctx.c:19:9: Taking false branch
  17.       TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  18.   
  19.       if (ctx == NULL)
                ^
  20.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  21.       return ctx;

crypto/ts/ts_verify_ctx.c:21:5: 
  19.       if (ctx == NULL)
  20.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  21. >     return ctx;
  22.   }
  23.   

crypto/ts/ts_verify_ctx.c:22:1: return from a call to TS_VERIFY_CTX_new
  20.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  21.       return ctx;
  22. > }
  23.   
  24.   void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx)

crypto/ts/ts_verify_ctx.c:112:14: Taking false branch
110.       if (ret)
111.           TS_VERIFY_CTX_cleanup(ret);
112.       else if ((ret = TS_VERIFY_CTX_new()) == NULL)
                    ^
113.           return NULL;
114.   

crypto/ts/ts_verify_ctx.c:115:5: 
113.           return NULL;
114.   
115. >     ret->flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE);
116.   
117.       if ((policy = req->policy_id) != NULL) {

crypto/ts/ts_verify_ctx.c:117:9: Taking true branch
115.       ret->flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE);
116.   
117.       if ((policy = req->policy_id) != NULL) {
               ^
118.           if ((ret->policy = OBJ_dup(policy)) == NULL)
119.               goto err;

crypto/ts/ts_verify_ctx.c:118:13: Taking true branch
116.   
117.       if ((policy = req->policy_id) != NULL) {
118.           if ((ret->policy = OBJ_dup(policy)) == NULL)
                   ^
119.               goto err;
120.       } else

crypto/ts/ts_verify_ctx.c:140:2: 
138.   
139.       return ret;
140. >  err:
141.       if (ctx)
142.           TS_VERIFY_CTX_cleanup(ctx);

crypto/ts/ts_verify_ctx.c:141:9: Taking false branch
139.       return ret;
140.    err:
141.       if (ctx)
               ^
142.           TS_VERIFY_CTX_cleanup(ctx);
143.       else

crypto/ts/ts_verify_ctx.c:144:9: 
142.           TS_VERIFY_CTX_cleanup(ctx);
143.       else
144. >         TS_VERIFY_CTX_free(ret);
145.       return NULL;
146.   }

crypto/ts/ts_verify_ctx.c:30:1: start of procedure TS_VERIFY_CTX_free()
  28.   }
  29.   
  30. > void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)
  31.   {
  32.       if (!ctx)

crypto/ts/ts_verify_ctx.c:32:10: Taking false branch
  30.   void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)
  31.   {
  32.       if (!ctx)
                 ^
  33.           return;
  34.   

crypto/ts/ts_verify_ctx.c:35:5: Skipping TS_VERIFY_CTX_cleanup(): empty list of specs
  33.           return;
  34.   
  35.       TS_VERIFY_CTX_cleanup(ctx);
            ^
  36.       OPENSSL_free(ctx);
  37.   }

crypto/ts/ts_verify_ctx.c:36:5: 
  34.   
  35.       TS_VERIFY_CTX_cleanup(ctx);
  36. >     OPENSSL_free(ctx);
  37.   }
  38.   

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/ts/ts_verify_ctx.c:37:1: return from a call to TS_VERIFY_CTX_free
  35.       TS_VERIFY_CTX_cleanup(ctx);
  36.       OPENSSL_free(ctx);
  37. > }
  38.   
  39.   int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f)

TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
{
    TS_VERIFY_CTX *ret = ctx;
    ASN1_OBJECT *policy;
    TS_MSG_IMPRINT *imprint;
    X509_ALGOR *md_alg;
    ASN1_OCTET_STRING *msg;
    const ASN1_INTEGER *nonce;
    OPENSSL_assert(req != NULL);
    if (ret)
        TS_VERIFY_CTX_cleanup(ret);
    else if ((ret = TS_VERIFY_CTX_new()) == NULL)
        return NULL;
    ret->flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE);
    if ((policy = req->policy_id) != NULL) {
        if ((ret->policy = OBJ_dup(policy)) == NULL)
            goto err;
    } else
        ret->flags &= ~TS_VFY_POLICY;
    imprint = req->msg_imprint;
    md_alg = imprint->hash_algo;
    if ((ret->md_alg = X509_ALGOR_dup(md_alg)) == NULL)
        goto err;
    msg = imprint->hashed_msg;
    ret->imprint_len = ASN1_STRING_length(msg);
    if ((ret->imprint = OPENSSL_malloc(ret->imprint_len)) == NULL)
        goto err;
    memcpy(ret->imprint, ASN1_STRING_get0_data(msg), ret->imprint_len);
    if ((nonce = req->nonce) != NULL) {
        if ((ret->nonce = ASN1_INTEGER_dup(nonce)) == NULL)
            goto err;
    } else
        ret->flags &= ~TS_VFY_NONCE;
    return ret;
 err:
    if (ctx)
        TS_VERIFY_CTX_cleanup(ctx);
    else
        TS_VERIFY_CTX_free(ret);
    return NULL;
}
['TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)\n{\n    TS_VERIFY_CTX *ret = ctx;\n    ASN1_OBJECT *policy;\n    TS_MSG_IMPRINT *imprint;\n    X509_ALGOR *md_alg;\n    ASN1_OCTET_STRING *msg;\n    const ASN1_INTEGER *nonce;\n    OPENSSL_assert(req != NULL);\n    if (ret)\n        TS_VERIFY_CTX_cleanup(ret);\n    else if ((ret = TS_VERIFY_CTX_new()) == NULL)\n        return NULL;\n    ret->flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE);\n    if ((policy = req->policy_id) != NULL) {\n        if ((ret->policy = OBJ_dup(policy)) == NULL)\n            goto err;\n    } else\n        ret->flags &= ~TS_VFY_POLICY;\n    imprint = req->msg_imprint;\n    md_alg = imprint->hash_algo;\n    if ((ret->md_alg = X509_ALGOR_dup(md_alg)) == NULL)\n        goto err;\n    msg = imprint->hashed_msg;\n    ret->imprint_len = ASN1_STRING_length(msg);\n    if ((ret->imprint = OPENSSL_malloc(ret->imprint_len)) == NULL)\n        goto err;\n    memcpy(ret->imprint, ASN1_STRING_get0_data(msg), ret->imprint_len);\n    if ((nonce = req->nonce) != NULL) {\n        if ((ret->nonce = ASN1_INTEGER_dup(nonce)) == NULL)\n            goto err;\n    } else\n        ret->flags &= ~TS_VFY_NONCE;\n    return ret;\n err:\n    if (ctx)\n        TS_VERIFY_CTX_cleanup(ctx);\n    else\n        TS_VERIFY_CTX_free(ret);\n    return NULL;\n}', 'TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)\n{\n    TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL)\n        TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);\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    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}', 'void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)\n{\n    if (!ctx)\n        return;\n    TS_VERIFY_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}']