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


crypto/evp/pmeth_gn.c:135:1: start of procedure EVP_PKEY_keygen()
133.   }
134.   
135. > int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
136.   {
137.       int ret;

crypto/evp/pmeth_gn.c:139:10: Taking false branch
137.       int ret;
138.   
139.       if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
                ^
140.           EVPerr(EVP_F_EVP_PKEY_KEYGEN,
141.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:139:18: Taking false branch
137.       int ret;
138.   
139.       if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
                        ^
140.           EVPerr(EVP_F_EVP_PKEY_KEYGEN,
141.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:139:33: Taking false branch
137.       int ret;
138.   
139.       if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
                                       ^
140.           EVPerr(EVP_F_EVP_PKEY_KEYGEN,
141.                  EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);

crypto/evp/pmeth_gn.c:144:9: Taking false branch
142.           return -2;
143.       }
144.       if (ctx->operation != EVP_PKEY_OP_KEYGEN) {
               ^
145.           EVPerr(EVP_F_EVP_PKEY_KEYGEN, EVP_R_OPERATON_NOT_INITIALIZED);
146.           return -1;

crypto/evp/pmeth_gn.c:149:9: Taking false branch
147.       }
148.   
149.       if (ppkey == NULL)
               ^
150.           return -1;
151.   

crypto/evp/pmeth_gn.c:152:9: Taking true branch
150.           return -1;
151.   
152.       if (*ppkey == NULL)
               ^
153.           *ppkey = EVP_PKEY_new();
154.       if (*ppkey == NULL)

crypto/evp/pmeth_gn.c:153:9: 
151.   
152.       if (*ppkey == NULL)
153. >         *ppkey = EVP_PKEY_new();
154.       if (*ppkey == NULL)
155.           return -1;

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:120:1: start of procedure CRYPTO_malloc()
    118.   }
    119.   
    120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    121.   {
    122.       void *ret = NULL;

crypto/mem.c:122:5: 
    120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    121.   {
    122. >     void *ret = NULL;
    123.   
    124.       if (num <= 0)

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

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

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

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

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

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

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
    153.   
    154.       return ret;
    155. > }
    156.   
    157.   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:154:9: Taking false branch
152.       if (*ppkey == NULL)
153.           *ppkey = EVP_PKEY_new();
154.       if (*ppkey == NULL)
               ^
155.           return -1;
156.   

crypto/evp/pmeth_gn.c:157:5: Skipping __function_pointer__(): unresolved function pointer
155.           return -1;
156.   
157.       ret = ctx->pmeth->keygen(ctx, *ppkey);
           ^
158.       if (ret <= 0) {
159.           EVP_PKEY_free(*ppkey);

crypto/evp/pmeth_gn.c:158:9: Taking true branch
156.   
157.       ret = ctx->pmeth->keygen(ctx, *ppkey);
158.       if (ret <= 0) {
               ^
159.           EVP_PKEY_free(*ppkey);
160.           *ppkey = NULL;

crypto/evp/pmeth_gn.c:159:9: 
157.       ret = ctx->pmeth->keygen(ctx, *ppkey);
158.       if (ret <= 0) {
159. >         EVP_PKEY_free(*ppkey);
160.           *ppkey = NULL;
161.       }

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:456:1: start of procedure CRYPTO_add_lock()
    454.   }
    455.   
    456. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    457.                       int line)
    458.   {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/lock.c:494:1: return from a call to CRYPTO_add_lock
    492.       }
    493.       return (ret);
    494. > }
    495.   
    496.   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:160:9: 
158.       if (ret <= 0) {
159.           EVP_PKEY_free(*ppkey);
160. >         *ppkey = NULL;
161.       }
162.       return ret;

int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)
{
    int ret;
    if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {
        EVPerr(EVP_F_EVP_PKEY_KEYGEN,
               EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
        return -2;
    }
    if (ctx->operation != EVP_PKEY_OP_KEYGEN) {
        EVPerr(EVP_F_EVP_PKEY_KEYGEN, EVP_R_OPERATON_NOT_INITIALIZED);
        return -1;
    }
    if (ppkey == NULL)
        return -1;
    if (*ppkey == NULL)
        *ppkey = EVP_PKEY_new();
    if (*ppkey == NULL)
        return -1;
    ret = ctx->pmeth->keygen(ctx, *ppkey);
    if (ret <= 0) {
        EVP_PKEY_free(*ppkey);
        *ppkey = NULL;
    }
    return ret;
}
['int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey)\n{\n    int ret;\n    if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) {\n        EVPerr(EVP_F_EVP_PKEY_KEYGEN,\n               EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);\n        return -2;\n    }\n    if (ctx->operation != EVP_PKEY_OP_KEYGEN) {\n        EVPerr(EVP_F_EVP_PKEY_KEYGEN, 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        return -1;\n    ret = ctx->pmeth->keygen(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#ifdef 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}']