crypto/evp/pmeth_lib.c:258: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 232, column 12 is not reachable after line 258, column 5.
Showing all 51 steps of the trace


crypto/evp/pmeth_lib.c:220:1: start of procedure EVP_PKEY_CTX_dup()
218.   }
219.   
220. > EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
221.   {
222.       EVP_PKEY_CTX *rctx;

crypto/evp/pmeth_lib.c:223:10: Taking false branch
221.   {
222.       EVP_PKEY_CTX *rctx;
223.       if (!pctx->pmeth || !pctx->pmeth->copy)
                ^
224.           return NULL;
225.   #ifndef OPENSSL_NO_ENGINE

crypto/evp/pmeth_lib.c:223:26: Taking false branch
221.   {
222.       EVP_PKEY_CTX *rctx;
223.       if (!pctx->pmeth || !pctx->pmeth->copy)
                                ^
224.           return NULL;
225.   #ifndef OPENSSL_NO_ENGINE

crypto/evp/pmeth_lib.c:227:9: Taking false branch
225.   #ifndef OPENSSL_NO_ENGINE
226.       /* Make sure it's safe to copy a pkey context using an ENGINE */
227.       if (pctx->engine && !ENGINE_init(pctx->engine)) {
               ^
228.           EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB);
229.           return 0;

crypto/evp/pmeth_lib.c:232:5: 
230.       }
231.   #endif
232. >     rctx = OPENSSL_malloc(sizeof(*rctx));
233.       if (rctx == NULL)
234.           return NULL;

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
  69.   }
  70.   
  71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73.       void *ret = NULL;

crypto/mem.c:73:5: 
  71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73. >     void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:78:9: Taking false branch
  76.           return malloc_impl(num, file, line);
  77.   
  78.       if (num <= 0)
                ^
  79.           return NULL;
  80.   

crypto/mem.c:81:5: 
  79.           return NULL;
  80.   
  81. >     allow_customize = 0;
  82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:91:24: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:92:5: 
  90.   #else
  91.       osslargused(file); osslargused(line);
  92. >     ret = malloc(num);
  93.   #endif
  94.   

crypto/mem.c:95:5: 
  93.   #endif
  94.   
  95. >     return ret;
  96.   }
  97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
  94.   
  95.       return ret;
  96. > }
  97.   
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/evp/pmeth_lib.c:233:9: Taking false branch
231.   #endif
232.       rctx = OPENSSL_malloc(sizeof(*rctx));
233.       if (rctx == NULL)
               ^
234.           return NULL;
235.   

crypto/evp/pmeth_lib.c:236:5: 
234.           return NULL;
235.   
236. >     rctx->pmeth = pctx->pmeth;
237.   #ifndef OPENSSL_NO_ENGINE
238.       rctx->engine = pctx->engine;

crypto/evp/pmeth_lib.c:238:5: 
236.       rctx->pmeth = pctx->pmeth;
237.   #ifndef OPENSSL_NO_ENGINE
238. >     rctx->engine = pctx->engine;
239.   #endif
240.   

crypto/evp/pmeth_lib.c:241:9: Taking true branch
239.   #endif
240.   
241.       if (pctx->pkey)
               ^
242.           EVP_PKEY_up_ref(pctx->pkey);
243.   

crypto/evp/pmeth_lib.c:242:9: 
240.   
241.       if (pctx->pkey)
242. >         EVP_PKEY_up_ref(pctx->pkey);
243.   
244.       rctx->pkey = pctx->pkey;

crypto/evp/p_lib.c:151:1: start of procedure EVP_PKEY_up_ref()
  149.   }
  150.   
  151. > int EVP_PKEY_up_ref(EVP_PKEY *pkey)
  152.   {
  153.       int i;

crypto/evp/p_lib.c:155:9: 
  153.       int i;
  154.   
  155. >     if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
  156.           return 0;
  157.   

crypto/threads_pthread.c:110:1: start of procedure CRYPTO_atomic_add()
    108.   }
    109.   
    110. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
    111.   {
    112.   #ifdef __ATOMIC_RELAXED

crypto/threads_pthread.c:113:5: 
    111.   {
    112.   #ifdef __ATOMIC_RELAXED
    113. >     *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);
    114.   #else
    115.       if (!CRYPTO_THREAD_write_lock(lock))

crypto/threads_pthread.c:125:5: 
    123.   #endif
    124.   
    125. >     return 1;
    126.   }
    127.   

crypto/threads_pthread.c:126:1: return from a call to CRYPTO_atomic_add
    124.   
    125.       return 1;
    126. > }
    127.   
    128.   #endif

crypto/evp/p_lib.c:155:9: Taking false branch
  153.       int i;
  154.   
  155.       if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
                 ^
  156.           return 0;
  157.   

crypto/evp/p_lib.c:160:14: Condition is false
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160.       return ((i > 1) ? 1 : 0);
                      ^
  161.   }
  162.   

crypto/evp/p_lib.c:160:13: 
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160. >     return ((i > 1) ? 1 : 0);
  161.   }
  162.   

crypto/evp/p_lib.c:160:5: 
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160. >     return ((i > 1) ? 1 : 0);
  161.   }
  162.   

crypto/evp/p_lib.c:161:1: return from a call to EVP_PKEY_up_ref
  159.       REF_ASSERT_ISNT(i < 2);
  160.       return ((i > 1) ? 1 : 0);
  161. > }
  162.   
  163.   /*

crypto/evp/pmeth_lib.c:244:5: 
242.           EVP_PKEY_up_ref(pctx->pkey);
243.   
244. >     rctx->pkey = pctx->pkey;
245.   
246.       if (pctx->peerkey)

crypto/evp/pmeth_lib.c:246:9: Taking true branch
244.       rctx->pkey = pctx->pkey;
245.   
246.       if (pctx->peerkey)
               ^
247.           EVP_PKEY_up_ref(pctx->peerkey);
248.   

crypto/evp/pmeth_lib.c:247:9: 
245.   
246.       if (pctx->peerkey)
247. >         EVP_PKEY_up_ref(pctx->peerkey);
248.   
249.       rctx->peerkey = pctx->peerkey;

crypto/evp/p_lib.c:151:1: start of procedure EVP_PKEY_up_ref()
  149.   }
  150.   
  151. > int EVP_PKEY_up_ref(EVP_PKEY *pkey)
  152.   {
  153.       int i;

crypto/evp/p_lib.c:155:9: 
  153.       int i;
  154.   
  155. >     if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
  156.           return 0;
  157.   

crypto/threads_pthread.c:110:1: start of procedure CRYPTO_atomic_add()
    108.   }
    109.   
    110. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
    111.   {
    112.   #ifdef __ATOMIC_RELAXED

crypto/threads_pthread.c:113:5: 
    111.   {
    112.   #ifdef __ATOMIC_RELAXED
    113. >     *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);
    114.   #else
    115.       if (!CRYPTO_THREAD_write_lock(lock))

crypto/threads_pthread.c:125:5: 
    123.   #endif
    124.   
    125. >     return 1;
    126.   }
    127.   

crypto/threads_pthread.c:126:1: return from a call to CRYPTO_atomic_add
    124.   
    125.       return 1;
    126. > }
    127.   
    128.   #endif

crypto/evp/p_lib.c:155:9: Taking false branch
  153.       int i;
  154.   
  155.       if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
                 ^
  156.           return 0;
  157.   

crypto/evp/p_lib.c:160:14: Condition is false
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160.       return ((i > 1) ? 1 : 0);
                      ^
  161.   }
  162.   

crypto/evp/p_lib.c:160:13: 
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160. >     return ((i > 1) ? 1 : 0);
  161.   }
  162.   

crypto/evp/p_lib.c:160:5: 
  158.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  159.       REF_ASSERT_ISNT(i < 2);
  160. >     return ((i > 1) ? 1 : 0);
  161.   }
  162.   

crypto/evp/p_lib.c:161:1: return from a call to EVP_PKEY_up_ref
  159.       REF_ASSERT_ISNT(i < 2);
  160.       return ((i > 1) ? 1 : 0);
  161. > }
  162.   
  163.   /*

crypto/evp/pmeth_lib.c:249:5: 
247.           EVP_PKEY_up_ref(pctx->peerkey);
248.   
249. >     rctx->peerkey = pctx->peerkey;
250.   
251.       rctx->data = NULL;

crypto/evp/pmeth_lib.c:251:5: 
249.       rctx->peerkey = pctx->peerkey;
250.   
251. >     rctx->data = NULL;
252.       rctx->app_data = NULL;
253.       rctx->operation = pctx->operation;

crypto/evp/pmeth_lib.c:252:5: 
250.   
251.       rctx->data = NULL;
252. >     rctx->app_data = NULL;
253.       rctx->operation = pctx->operation;
254.   

crypto/evp/pmeth_lib.c:253:5: 
251.       rctx->data = NULL;
252.       rctx->app_data = NULL;
253. >     rctx->operation = pctx->operation;
254.   
255.       if (pctx->pmeth->copy(rctx, pctx) > 0)

crypto/evp/pmeth_lib.c:255:9: Taking false branch
253.       rctx->operation = pctx->operation;
254.   
255.       if (pctx->pmeth->copy(rctx, pctx) > 0)
               ^
256.           return rctx;
257.   

crypto/evp/pmeth_lib.c:258:5: Skipping EVP_PKEY_CTX_free(): empty list of specs
256.           return rctx;
257.   
258.       EVP_PKEY_CTX_free(rctx);
           ^
259.       return NULL;
260.   

EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
{
    EVP_PKEY_CTX *rctx;
    if (!pctx->pmeth || !pctx->pmeth->copy)
        return NULL;
#ifndef OPENSSL_NO_ENGINE
    if (pctx->engine && !ENGINE_init(pctx->engine)) {
        EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB);
        return 0;
    }
#endif
    rctx = OPENSSL_malloc(sizeof(*rctx));
    if (rctx == NULL)
        return NULL;
    rctx->pmeth = pctx->pmeth;
#ifndef OPENSSL_NO_ENGINE
    rctx->engine = pctx->engine;
#endif
    if (pctx->pkey)
        EVP_PKEY_up_ref(pctx->pkey);
    rctx->pkey = pctx->pkey;
    if (pctx->peerkey)
        EVP_PKEY_up_ref(pctx->peerkey);
    rctx->peerkey = pctx->peerkey;
    rctx->data = NULL;
    rctx->app_data = NULL;
    rctx->operation = pctx->operation;
    if (pctx->pmeth->copy(rctx, pctx) > 0)
        return rctx;
    EVP_PKEY_CTX_free(rctx);
    return NULL;
}
['EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)\n{\n    EVP_PKEY_CTX *rctx;\n    if (!pctx->pmeth || !pctx->pmeth->copy)\n        return NULL;\n#ifndef OPENSSL_NO_ENGINE\n    if (pctx->engine && !ENGINE_init(pctx->engine)) {\n        EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB);\n        return 0;\n    }\n#endif\n    rctx = OPENSSL_malloc(sizeof(*rctx));\n    if (rctx == NULL)\n        return NULL;\n    rctx->pmeth = pctx->pmeth;\n#ifndef OPENSSL_NO_ENGINE\n    rctx->engine = pctx->engine;\n#endif\n    if (pctx->pkey)\n        EVP_PKEY_up_ref(pctx->pkey);\n    rctx->pkey = pctx->pkey;\n    if (pctx->peerkey)\n        EVP_PKEY_up_ref(pctx->peerkey);\n    rctx->peerkey = pctx->peerkey;\n    rctx->data = NULL;\n    rctx->app_data = NULL;\n    rctx->operation = pctx->operation;\n    if (pctx->pmeth->copy(rctx, pctx) > 0)\n        return rctx;\n    EVP_PKEY_CTX_free(rctx);\n    return NULL;\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}', 'int EVP_PKEY_up_ref(EVP_PKEY *pkey)\n{\n    int i;\n    if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)\n        return 0;\n    REF_PRINT_COUNT("EVP_PKEY", pkey);\n    REF_ASSERT_ISNT(i < 2);\n    return ((i > 1) ? 1 : 0);\n}', 'int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)\n{\n#ifdef __ATOMIC_RELAXED\n    *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);\n#else\n    if (!CRYPTO_THREAD_write_lock(lock))\n        return 0;\n    *val += amount;\n    *ret  = *val;\n    if (!CRYPTO_THREAD_unlock(lock))\n        return 0;\n#endif\n    return 1;\n}']