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


crypto/evp/pmeth_lib.c:269:1: start of procedure EVP_PKEY_CTX_dup()
267.   }
268.   
269. > EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
270.   {
271.       EVP_PKEY_CTX *rctx;

crypto/evp/pmeth_lib.c:272:10: Taking false branch
270.   {
271.       EVP_PKEY_CTX *rctx;
272.       if (!pctx->pmeth || !pctx->pmeth->copy)
                ^
273.           return NULL;
274.   #ifndef OPENSSL_NO_ENGINE

crypto/evp/pmeth_lib.c:272:26: Taking false branch
270.   {
271.       EVP_PKEY_CTX *rctx;
272.       if (!pctx->pmeth || !pctx->pmeth->copy)
                                ^
273.           return NULL;
274.   #ifndef OPENSSL_NO_ENGINE

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

crypto/evp/pmeth_lib.c:281:5: 
279.       }
280.   #endif
281. >     rctx = OPENSSL_malloc(sizeof(*rctx));
282.       if (rctx == NULL)
283.           return 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/evp/pmeth_lib.c:282:9: Taking false branch
280.   #endif
281.       rctx = OPENSSL_malloc(sizeof(*rctx));
282.       if (rctx == NULL)
               ^
283.           return NULL;
284.   

crypto/evp/pmeth_lib.c:285:5: 
283.           return NULL;
284.   
285. >     rctx->pmeth = pctx->pmeth;
286.   #ifndef OPENSSL_NO_ENGINE
287.       rctx->engine = pctx->engine;

crypto/evp/pmeth_lib.c:287:5: 
285.       rctx->pmeth = pctx->pmeth;
286.   #ifndef OPENSSL_NO_ENGINE
287. >     rctx->engine = pctx->engine;
288.   #endif
289.   

crypto/evp/pmeth_lib.c:290:9: Taking true branch
288.   #endif
289.   
290.       if (pctx->pkey)
               ^
291.           EVP_PKEY_up_ref(pctx->pkey);
292.   

crypto/evp/pmeth_lib.c:291:9: 
289.   
290.       if (pctx->pkey)
291. >         EVP_PKEY_up_ref(pctx->pkey);
292.   
293.       rctx->pkey = pctx->pkey;

crypto/evp/p_lib.c:208:1: start of procedure EVP_PKEY_up_ref()
  206.   }
  207.   
  208. > void EVP_PKEY_up_ref(EVP_PKEY *pkey)
  209.   {
  210.       int i;

crypto/evp/p_lib.c:211:5: 
  209.   {
  210.       int i;
  211. >     CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock);
  212.   }
  213.   

crypto/threads_pthread.c:151:1: start of procedure CRYPTO_atomic_add()
    149.   }
    150.   
    151. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
    152.   {
    153.   #ifdef __ATOMIC_RELAXED

crypto/threads_pthread.c:154:5: 
    152.   {
    153.   #ifdef __ATOMIC_RELAXED
    154. >     *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);
    155.   #else
    156.       if (!CRYPTO_THREAD_write_lock(lock))

crypto/threads_pthread.c:166:5: 
    164.   #endif
    165.   
    166. >     return 1;
    167.   }
    168.   

crypto/threads_pthread.c:167:1: return from a call to CRYPTO_atomic_add
    165.   
    166.       return 1;
    167. > }
    168.   
    169.   #endif

crypto/evp/p_lib.c:212:1: return from a call to EVP_PKEY_up_ref
  210.       int i;
  211.       CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock);
  212. > }
  213.   
  214.   /*

crypto/evp/pmeth_lib.c:293:5: 
291.           EVP_PKEY_up_ref(pctx->pkey);
292.   
293. >     rctx->pkey = pctx->pkey;
294.   
295.       if (pctx->peerkey)

crypto/evp/pmeth_lib.c:295:9: Taking true branch
293.       rctx->pkey = pctx->pkey;
294.   
295.       if (pctx->peerkey)
               ^
296.           EVP_PKEY_up_ref(pctx->peerkey);
297.   

crypto/evp/pmeth_lib.c:296:9: 
294.   
295.       if (pctx->peerkey)
296. >         EVP_PKEY_up_ref(pctx->peerkey);
297.   
298.       rctx->peerkey = pctx->peerkey;

crypto/evp/p_lib.c:208:1: start of procedure EVP_PKEY_up_ref()
  206.   }
  207.   
  208. > void EVP_PKEY_up_ref(EVP_PKEY *pkey)
  209.   {
  210.       int i;

crypto/evp/p_lib.c:211:5: 
  209.   {
  210.       int i;
  211. >     CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock);
  212.   }
  213.   

crypto/threads_pthread.c:151:1: start of procedure CRYPTO_atomic_add()
    149.   }
    150.   
    151. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
    152.   {
    153.   #ifdef __ATOMIC_RELAXED

crypto/threads_pthread.c:154:5: 
    152.   {
    153.   #ifdef __ATOMIC_RELAXED
    154. >     *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);
    155.   #else
    156.       if (!CRYPTO_THREAD_write_lock(lock))

crypto/threads_pthread.c:166:5: 
    164.   #endif
    165.   
    166. >     return 1;
    167.   }
    168.   

crypto/threads_pthread.c:167:1: return from a call to CRYPTO_atomic_add
    165.   
    166.       return 1;
    167. > }
    168.   
    169.   #endif

crypto/evp/p_lib.c:212:1: return from a call to EVP_PKEY_up_ref
  210.       int i;
  211.       CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock);
  212. > }
  213.   
  214.   /*

crypto/evp/pmeth_lib.c:298:5: 
296.           EVP_PKEY_up_ref(pctx->peerkey);
297.   
298. >     rctx->peerkey = pctx->peerkey;
299.   
300.       rctx->data = NULL;

crypto/evp/pmeth_lib.c:300:5: 
298.       rctx->peerkey = pctx->peerkey;
299.   
300. >     rctx->data = NULL;
301.       rctx->app_data = NULL;
302.       rctx->operation = pctx->operation;

crypto/evp/pmeth_lib.c:301:5: 
299.   
300.       rctx->data = NULL;
301. >     rctx->app_data = NULL;
302.       rctx->operation = pctx->operation;
303.   

crypto/evp/pmeth_lib.c:302:5: 
300.       rctx->data = NULL;
301.       rctx->app_data = NULL;
302. >     rctx->operation = pctx->operation;
303.   
304.       if (pctx->pmeth->copy(rctx, pctx) > 0)

crypto/evp/pmeth_lib.c:304:9: Taking false branch
302.       rctx->operation = pctx->operation;
303.   
304.       if (pctx->pmeth->copy(rctx, pctx) > 0)
               ^
305.           return rctx;
306.   

crypto/evp/pmeth_lib.c:307:5: Skipping EVP_PKEY_CTX_free(): empty list of specs
305.           return rctx;
306.   
307.       EVP_PKEY_CTX_free(rctx);
           ^
308.       return NULL;
309.   

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}', 'void EVP_PKEY_up_ref(EVP_PKEY *pkey)\n{\n    int i;\n    CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock);\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}']