crypto/evp/pmeth_gn.c:112: error: MEMORY_LEAK
  memory dynamically allocated to `*ppkey` by call to `EVP_PKEY_new()` at line 102, column 18 is not reachable after line 112, column 9.
Showing all 60 steps of the trace


crypto/evp/pmeth_gn.c:84:1: start of procedure EVP_PKEY_paramgen()
82.   }
83.   
84. > int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
85.   {
86.       int ret;

crypto/evp/pmeth_gn.c:87:10: Taking false branch
85.   {
86.       int ret;
87.       if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
               ^
88.           EVPerr(EVP_F_EVP_PKEY_PARAMGEN,
89.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:87:18: Taking false branch
85.   {
86.       int ret;
87.       if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
                       ^
88.           EVPerr(EVP_F_EVP_PKEY_PARAMGEN,
89.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:87:33: Taking false branch
85.   {
86.       int ret;
87.       if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
                                      ^
88.           EVPerr(EVP_F_EVP_PKEY_PARAMGEN,
89.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:93:9: Taking false branch
91.       }
92.   
93.       if (ctx->operation != EVP_PKEY_OP_PARAMGEN) {
              ^
94.           EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATON_NOT_INITIALIZED);
95.           return -1;

crypto/evp/pmeth_gn.c:98:9: Taking false branch
96.       }
97.   
98.       if (ppkey == NULL)
               ^
99.           return -1;
100.   

crypto/evp/pmeth_gn.c:101:9: Taking true branch
99.           return -1;
100.   
101.       if (*ppkey == NULL)
               ^
102.           *ppkey = EVP_PKEY_new();
103.   

crypto/evp/pmeth_gn.c:102:9: 
100.   
101.       if (*ppkey == NULL)
102. >         *ppkey = EVP_PKEY_new();
103.   
104.       if (*ppkey == NULL) {

crypto/evp/p_lib.c:187:1: start of procedure EVP_PKEY_new()
  185.   }
  186.   
  187. > EVP_PKEY *EVP_PKEY_new(void)
  188.   {
  189.       EVP_PKEY *ret;

crypto/evp/p_lib.c:191:5: 
  189.       EVP_PKEY *ret;
  190.   
  191. >     ret = OPENSSL_malloc(sizeof(*ret));
  192.       if (ret == NULL) {
  193.           EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);

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 (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

crypto/mem.c:126:5: 
    124.           return NULL;
    125.   
    126. >     allow_customize = 0;
    127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
    152.   
    153.       return ret;
    154. > }
    155.   
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/evp/p_lib.c:192:9: Taking false branch
  190.   
  191.       ret = OPENSSL_malloc(sizeof(*ret));
  192.       if (ret == NULL) {
                 ^
  193.           EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);
  194.           return (NULL);

crypto/evp/p_lib.c:196:5: 
  194.           return (NULL);
  195.       }
  196. >     ret->type = EVP_PKEY_NONE;
  197.       ret->save_type = EVP_PKEY_NONE;
  198.       ret->references = 1;

crypto/evp/p_lib.c:197:5: 
  195.       }
  196.       ret->type = EVP_PKEY_NONE;
  197. >     ret->save_type = EVP_PKEY_NONE;
  198.       ret->references = 1;
  199.       ret->ameth = NULL;

crypto/evp/p_lib.c:198:5: 
  196.       ret->type = EVP_PKEY_NONE;
  197.       ret->save_type = EVP_PKEY_NONE;
  198. >     ret->references = 1;
  199.       ret->ameth = NULL;
  200.       ret->engine = NULL;

crypto/evp/p_lib.c:199:5: 
  197.       ret->save_type = EVP_PKEY_NONE;
  198.       ret->references = 1;
  199. >     ret->ameth = NULL;
  200.       ret->engine = NULL;
  201.       ret->pkey.ptr = NULL;

crypto/evp/p_lib.c:200:5: 
  198.       ret->references = 1;
  199.       ret->ameth = NULL;
  200. >     ret->engine = NULL;
  201.       ret->pkey.ptr = NULL;
  202.       ret->attributes = NULL;

crypto/evp/p_lib.c:201:5: 
  199.       ret->ameth = NULL;
  200.       ret->engine = NULL;
  201. >     ret->pkey.ptr = NULL;
  202.       ret->attributes = NULL;
  203.       ret->save_parameters = 1;

crypto/evp/p_lib.c:202:5: 
  200.       ret->engine = NULL;
  201.       ret->pkey.ptr = NULL;
  202. >     ret->attributes = NULL;
  203.       ret->save_parameters = 1;
  204.       return (ret);

crypto/evp/p_lib.c:203:5: 
  201.       ret->pkey.ptr = NULL;
  202.       ret->attributes = NULL;
  203. >     ret->save_parameters = 1;
  204.       return (ret);
  205.   }

crypto/evp/p_lib.c:204:5: 
  202.       ret->attributes = NULL;
  203.       ret->save_parameters = 1;
  204. >     return (ret);
  205.   }
  206.   

crypto/evp/p_lib.c:205:1: return from a call to EVP_PKEY_new
  203.       ret->save_parameters = 1;
  204.       return (ret);
  205. > }
  206.   
  207.   void EVP_PKEY_up_ref(EVP_PKEY *pkey)

crypto/evp/pmeth_gn.c:104:9: Taking false branch
102.           *ppkey = EVP_PKEY_new();
103.   
104.       if (*ppkey == NULL) {
               ^
105.           EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);
106.           return -1;

crypto/evp/pmeth_gn.c:109:5: Skipping __function_pointer__(): unresolved function pointer
107.       }
108.   
109.       ret = ctx->pmeth->paramgen(ctx, *ppkey);
           ^
110.       if (ret <= 0) {
111.           EVP_PKEY_free(*ppkey);

crypto/evp/pmeth_gn.c:110:9: Taking true branch
108.   
109.       ret = ctx->pmeth->paramgen(ctx, *ppkey);
110.       if (ret <= 0) {
               ^
111.           EVP_PKEY_free(*ppkey);
112.           *ppkey = NULL;

crypto/evp/pmeth_gn.c:111:9: 
109.       ret = ctx->pmeth->paramgen(ctx, *ppkey);
110.       if (ret <= 0) {
111. >         EVP_PKEY_free(*ppkey);
112.           *ppkey = NULL;
113.       }

crypto/evp/p_lib.c:420:1: start of procedure EVP_PKEY_free()
  418.   }
  419.   
  420. > void EVP_PKEY_free(EVP_PKEY *x)
  421.   {
  422.       int i;

crypto/evp/p_lib.c:424:9: Taking false branch
  422.       int i;
  423.   
  424.       if (x == NULL)
                 ^
  425.           return;
  426.   

crypto/evp/p_lib.c:427:5: 
  425.           return;
  426.   
  427. >     i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);
  428.   #ifdef REF_PRINT
  429.       REF_PRINT("EVP_PKEY", x);

crypto/lock.c:455:1: start of procedure CRYPTO_add_lock()
    453.   }
    454.   
    455. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    456.                       int line)
    457.   {

crypto/lock.c:458:5: 
    456.                       int line)
    457.   {
    458. >     int ret = 0;
    459.   
    460.       if (add_lock_callback != NULL) {

crypto/lock.c:460:9: Taking false branch
    458.       int ret = 0;
    459.   
    460.       if (add_lock_callback != NULL) {
                   ^
    461.   #ifdef LOCK_DEBUG
    462.           int before = *pointer;

crypto/lock.c:476:9: 
    474.   #endif
    475.       } else {
    476. >         CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    477.   
    478.           ret = *pointer + amount;

crypto/lock.c:413:1: start of procedure CRYPTO_lock()
      411.   }
      412.   
      413. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      414.   {
      415.   #ifdef LOCK_DEBUG

crypto/lock.c:440:9: Taking false branch
      438.       }
      439.   #endif
      440.       if (type < 0) {
                     ^
      441.           if (dynlock_lock_callback != NULL) {
      442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:451:16: Taking false branch
      449.               CRYPTO_destroy_dynlockid(type);
      450.           }
      451.       } else if (locking_callback != NULL)
                            ^
      452.           locking_callback(mode, type, file, line);
      453.   }

crypto/lock.c:440:5: 
      438.       }
      439.   #endif
      440. >     if (type < 0) {
      441.           if (dynlock_lock_callback != NULL) {
      442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:453:1: return from a call to CRYPTO_lock
      451.       } else if (locking_callback != NULL)
      452.           locking_callback(mode, type, file, line);
      453. > }
      454.   
      455.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:478:9: 
    476.           CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    477.   
    478. >         ret = *pointer + amount;
    479.   #ifdef LOCK_DEBUG
    480.           {

crypto/lock.c:489:9: 
    487.           }
    488.   #endif
    489. >         *pointer = ret;
    490.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    491.       }

crypto/lock.c:490:9: 
    488.   #endif
    489.           *pointer = ret;
    490. >         CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    491.       }
    492.       return (ret);

crypto/lock.c:413:1: start of procedure CRYPTO_lock()
      411.   }
      412.   
      413. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      414.   {
      415.   #ifdef LOCK_DEBUG

crypto/lock.c:440:9: Taking false branch
      438.       }
      439.   #endif
      440.       if (type < 0) {
                     ^
      441.           if (dynlock_lock_callback != NULL) {
      442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:451:16: Taking false branch
      449.               CRYPTO_destroy_dynlockid(type);
      450.           }
      451.       } else if (locking_callback != NULL)
                            ^
      452.           locking_callback(mode, type, file, line);
      453.   }

crypto/lock.c:440:5: 
      438.       }
      439.   #endif
      440. >     if (type < 0) {
      441.           if (dynlock_lock_callback != NULL) {
      442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:453:1: return from a call to CRYPTO_lock
      451.       } else if (locking_callback != NULL)
      452.           locking_callback(mode, type, file, line);
      453. > }
      454.   
      455.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:492:5: 
    490.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    491.       }
    492. >     return (ret);
    493.   }
    494.   

crypto/lock.c:493:1: return from a call to CRYPTO_add_lock
    491.       }
    492.       return (ret);
    493. > }
    494.   
    495.   const char *CRYPTO_get_lock_name(int type)

crypto/evp/p_lib.c:431:9: Taking true branch
  429.       REF_PRINT("EVP_PKEY", x);
  430.   #endif
  431.       if (i > 0)
                 ^
  432.           return;
  433.   #ifdef REF_CHECK

crypto/evp/p_lib.c:432:9: 
  430.   #endif
  431.       if (i > 0)
  432. >         return;
  433.   #ifdef REF_CHECK
  434.       if (i < 0) {

crypto/evp/p_lib.c:442:1: return from a call to EVP_PKEY_free
  440.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
  441.       OPENSSL_free(x);
  442. > }
  443.   
  444.   static void EVP_PKEY_free_it(EVP_PKEY *x)

crypto/evp/pmeth_gn.c:112:9: 
110.       if (ret <= 0) {
111.           EVP_PKEY_free(*ppkey);
112. >         *ppkey = NULL;
113.       }
114.       return ret;

int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
{
    int ret;
    if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {
        EVPerr(EVP_F_EVP_PKEY_PARAMGEN,
               EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
        return -2;
    }
    if (ctx->operation != EVP_PKEY_OP_PARAMGEN) {
        EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATON_NOT_INITIALIZED);
        return -1;
    }
    if (ppkey == NULL)
        return -1;
    if (*ppkey == NULL)
        *ppkey = EVP_PKEY_new();
    if (*ppkey == NULL) {
        EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);
        return -1;
    }
    ret = ctx->pmeth->paramgen(ctx, *ppkey);
    if (ret <= 0) {
        EVP_PKEY_free(*ppkey);
        *ppkey = NULL;
    }
    return ret;
}
['int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)\n{\n    int ret;\n    if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) {\n        EVPerr(EVP_F_EVP_PKEY_PARAMGEN,\n               EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);\n        return -2;\n    }\n    if (ctx->operation != EVP_PKEY_OP_PARAMGEN) {\n        EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATON_NOT_INITIALIZED);\n        return -1;\n    }\n    if (ppkey == NULL)\n        return -1;\n    if (*ppkey == NULL)\n        *ppkey = EVP_PKEY_new();\n    if (*ppkey == NULL) {\n        EVPerr(EVP_F_EVP_PKEY_PARAMGEN, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    ret = ctx->pmeth->paramgen(ctx, *ppkey);\n    if (ret <= 0) {\n        EVP_PKEY_free(*ppkey);\n        *ppkey = NULL;\n    }\n    return ret;\n}', 'EVP_PKEY *EVP_PKEY_new(void)\n{\n    EVP_PKEY *ret;\n    ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL) {\n        EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->type = EVP_PKEY_NONE;\n    ret->save_type = EVP_PKEY_NONE;\n    ret->references = 1;\n    ret->ameth = NULL;\n    ret->engine = NULL;\n    ret->pkey.ptr = NULL;\n    ret->attributes = NULL;\n    ret->save_parameters = 1;\n    return (ret);\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'void EVP_PKEY_free(EVP_PKEY *x)\n{\n    int i;\n    if (x == NULL)\n        return;\n    i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);\n#ifdef REF_PRINT\n    REF_PRINT("EVP_PKEY", x);\n#endif\n    if (i > 0)\n        return;\n#ifdef REF_CHECK\n    if (i < 0) {\n        fprintf(stderr, "EVP_PKEY_free, bad reference count\\n");\n        abort();\n    }\n#endif\n    EVP_PKEY_free_it(x);\n    sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);\n    OPENSSL_free(x);\n}', 'int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line)\n{\n    int ret = 0;\n    if (add_lock_callback != NULL) {\n#ifdef LOCK_DEBUG\n        int before = *pointer;\n#endif\n        ret = add_lock_callback(pointer, amount, type, file, line);\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id), before, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n    } else {\n        CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);\n        ret = *pointer + amount;\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id),\n                    *pointer, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n        *pointer = ret;\n        CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);\n    }\n    return (ret);\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}']