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


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

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

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

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

crypto/evp/pmeth_lib.c:235:5: 
233.       }
234.   #endif
235. >     rctx = OPENSSL_malloc(sizeof(*rctx));
236.       if (rctx == NULL)
237.           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:236:9: Taking false branch
234.   #endif
235.       rctx = OPENSSL_malloc(sizeof(*rctx));
236.       if (rctx == NULL)
               ^
237.           return NULL;
238.   

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

crypto/evp/pmeth_lib.c:241:5: 
239.       rctx->pmeth = pctx->pmeth;
240.   #ifndef OPENSSL_NO_ENGINE
241. >     rctx->engine = pctx->engine;
242.   #endif
243.   

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

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

crypto/evp/p_lib.c:159:1: start of procedure EVP_PKEY_up_ref()
  157.   }
  158.   
  159. > int EVP_PKEY_up_ref(EVP_PKEY *pkey)
  160.   {
  161.       int i;

crypto/evp/p_lib.c:163:9: 
  161.       int i;
  162.   
  163. >     if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
  164.           return 0;
  165.   

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.   # if defined(__GNUC__) && defined(__ATOMIC_RELAXED)

crypto/threads_pthread.c:113:5: 
    111.   {
    112.   # if defined(__GNUC__) && defined(__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:163:9: Taking false branch
  161.       int i;
  162.   
  163.       if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
                 ^
  164.           return 0;
  165.   

crypto/evp/p_lib.c:168:14: Condition is false
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168.       return ((i > 1) ? 1 : 0);
                      ^
  169.   }
  170.   

crypto/evp/p_lib.c:168:13: 
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168. >     return ((i > 1) ? 1 : 0);
  169.   }
  170.   

crypto/evp/p_lib.c:168:5: 
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168. >     return ((i > 1) ? 1 : 0);
  169.   }
  170.   

crypto/evp/p_lib.c:169:1: return from a call to EVP_PKEY_up_ref
  167.       REF_ASSERT_ISNT(i < 2);
  168.       return ((i > 1) ? 1 : 0);
  169. > }
  170.   
  171.   /*

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

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

crypto/evp/pmeth_lib.c:250:9: 
248.   
249.       if (pctx->peerkey)
250. >         EVP_PKEY_up_ref(pctx->peerkey);
251.   
252.       rctx->peerkey = pctx->peerkey;

crypto/evp/p_lib.c:159:1: start of procedure EVP_PKEY_up_ref()
  157.   }
  158.   
  159. > int EVP_PKEY_up_ref(EVP_PKEY *pkey)
  160.   {
  161.       int i;

crypto/evp/p_lib.c:163:9: 
  161.       int i;
  162.   
  163. >     if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
  164.           return 0;
  165.   

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.   # if defined(__GNUC__) && defined(__ATOMIC_RELAXED)

crypto/threads_pthread.c:113:5: 
    111.   {
    112.   # if defined(__GNUC__) && defined(__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:163:9: Taking false branch
  161.       int i;
  162.   
  163.       if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0)
                 ^
  164.           return 0;
  165.   

crypto/evp/p_lib.c:168:14: Condition is false
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168.       return ((i > 1) ? 1 : 0);
                      ^
  169.   }
  170.   

crypto/evp/p_lib.c:168:13: 
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168. >     return ((i > 1) ? 1 : 0);
  169.   }
  170.   

crypto/evp/p_lib.c:168:5: 
  166.       REF_PRINT_COUNT("EVP_PKEY", pkey);
  167.       REF_ASSERT_ISNT(i < 2);
  168. >     return ((i > 1) ? 1 : 0);
  169.   }
  170.   

crypto/evp/p_lib.c:169:1: return from a call to EVP_PKEY_up_ref
  167.       REF_ASSERT_ISNT(i < 2);
  168.       return ((i > 1) ? 1 : 0);
  169. > }
  170.   
  171.   /*

crypto/evp/pmeth_lib.c:252:5: 
250.           EVP_PKEY_up_ref(pctx->peerkey);
251.   
252. >     rctx->peerkey = pctx->peerkey;
253.   
254.       rctx->data = NULL;

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

crypto/evp/pmeth_lib.c:255:5: 
253.   
254.       rctx->data = NULL;
255. >     rctx->app_data = NULL;
256.       rctx->operation = pctx->operation;
257.   

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

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

crypto/evp/pmeth_lib.c:261:5: Skipping EVP_PKEY_CTX_free(): empty list of specs
259.           return rctx;
260.   
261.       EVP_PKEY_CTX_free(rctx);
           ^
262.       return NULL;
263.   

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# if defined(__GNUC__) && defined(__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}']