crypto/ec/ecx_meth.c:114: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `CRYPTO_memdup()` at line 102, column 12 is not reachable after line 114, column 5.
Showing all 32 steps of the trace


crypto/ec/ecx_meth.c:92:1: start of procedure ecx_pub_encode()
90.   }
91.   
92. > static int ecx_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
93.   {
94.       const X25519_KEY *xkey = pkey->pkey.ptr;

crypto/ec/ecx_meth.c:94:5: 
92.   static int ecx_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
93.   {
94. >     const X25519_KEY *xkey = pkey->pkey.ptr;
95.       unsigned char *penc;
96.   

crypto/ec/ecx_meth.c:97:9: Taking false branch
95.       unsigned char *penc;
96.   
97.       if (xkey == NULL) {
               ^
98.           ECerr(EC_F_ECX_PUB_ENCODE, EC_R_INVALID_KEY);
99.           return 0;

crypto/ec/ecx_meth.c:102:5: 
100.       }
101.   
102. >     penc = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);
103.       if (penc == NULL) {
104.           ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);

crypto/o_str.c:60:1: start of procedure CRYPTO_memdup()
  58.   }
  59.   
  60. > void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)
  61.   {
  62.       void *ret;

crypto/o_str.c:64:9: Taking false branch
  62.       void *ret;
  63.   
  64.       if (data == NULL || siz >= INT_MAX)
                ^
  65.           return NULL;
  66.   

crypto/o_str.c:64:25: Taking false branch
  62.       void *ret;
  63.   
  64.       if (data == NULL || siz >= INT_MAX)
                                ^
  65.           return NULL;
  66.   

crypto/o_str.c:67:5: 
  65.           return NULL;
  66.   
  67. >     ret = CRYPTO_malloc(siz, file, line);
  68.       if (ret == NULL) {
  69.           CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);

crypto/mem.c:157:1: start of procedure CRYPTO_malloc()
    155.   #endif
    156.   
    157. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = NULL;

crypto/mem.c:159:5: 
    157.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = NULL;
    160.   
    161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:161:9: Taking false branch
    159.       void *ret = NULL;
    160.   
    161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    162.           return malloc_impl(num, file, line);
    163.   

crypto/mem.c:164:9: Taking false branch
    162.           return malloc_impl(num, file, line);
    163.   
    164.       if (num <= 0)
                   ^
    165.           return NULL;
    166.   

crypto/mem.c:168:5: 
    166.   
    167.       FAILTEST();
    168. >     allow_customize = 0;
    169.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    170.       if (call_malloc_debug) {

crypto/mem.c:178:5: 
    176.       }
    177.   #else
    178. >     osslargused(file); osslargused(line);
    179.       ret = malloc(num);
    180.   #endif

crypto/mem.c:178:24: 
    176.       }
    177.   #else
    178. >     osslargused(file); osslargused(line);
    179.       ret = malloc(num);
    180.   #endif

crypto/mem.c:179:5: 
    177.   #else
    178.       osslargused(file); osslargused(line);
    179. >     ret = malloc(num);
    180.   #endif
    181.   

crypto/mem.c:182:5: 
    180.   #endif
    181.   
    182. >     return ret;
    183.   }
    184.   

crypto/mem.c:183:1: return from a call to CRYPTO_malloc
    181.   
    182.       return ret;
    183. > }
    184.   
    185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:68:9: Taking false branch
  66.   
  67.       ret = CRYPTO_malloc(siz, file, line);
  68.       if (ret == NULL) {
                ^
  69.           CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);
  70.           return NULL;

crypto/o_str.c:72:5: 
  70.           return NULL;
  71.       }
  72. >     return memcpy(ret, data, siz);
  73.   }
  74.   

crypto/o_str.c:73:1: return from a call to CRYPTO_memdup
  71.       }
  72.       return memcpy(ret, data, siz);
  73. > }
  74.   
  75.   size_t OPENSSL_strnlen(const char *str, size_t maxlen)

crypto/ec/ecx_meth.c:103:9: Taking false branch
101.   
102.       penc = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);
103.       if (penc == NULL) {
               ^
104.           ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
105.           return 0;

crypto/ec/ecx_meth.c:108:10: 
106.       }
107.   
108. >     if (!X509_PUBKEY_set0_param(pk, OBJ_nid2obj(NID_X25519), V_ASN1_UNDEF,
109.                                   NULL, penc, X25519_KEYLEN)) {
110.           OPENSSL_free(penc);

crypto/objects/obj_dat.c:220:1: start of procedure OBJ_nid2obj()
  218.   }
  219.   
  220. > ASN1_OBJECT *OBJ_nid2obj(int n)
  221.   {
  222.       ADDED_OBJ ad, *adp;

crypto/objects/obj_dat.c:225:10: Taking true branch
  223.       ASN1_OBJECT ob;
  224.   
  225.       if ((n >= 0) && (n < NUM_NID)) {
                  ^
  226.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  227.               OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:225:22: Taking true branch
  223.       ASN1_OBJECT ob;
  224.   
  225.       if ((n >= 0) && (n < NUM_NID)) {
                              ^
  226.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  227.               OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:226:14: Taking true branch
  224.   
  225.       if ((n >= 0) && (n < NUM_NID)) {
  226.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
                      ^
  227.               OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
  228.               return (NULL);

crypto/objects/obj_dat.c:226:34: Taking false branch
  224.   
  225.       if ((n >= 0) && (n < NUM_NID)) {
  226.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
                                          ^
  227.               OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
  228.               return (NULL);

crypto/objects/obj_dat.c:230:9: 
  228.               return (NULL);
  229.           }
  230. >         return ((ASN1_OBJECT *)&(nid_objs[n]));
  231.       } else if (added == NULL)
  232.           return (NULL);

crypto/objects/obj_dat.c:245:1: return from a call to OBJ_nid2obj
  243.           }
  244.       }
  245. > }
  246.   
  247.   const char *OBJ_nid2sn(int n)

crypto/ec/ecx_meth.c:108:10: Taking false branch
106.       }
107.   
108.       if (!X509_PUBKEY_set0_param(pk, OBJ_nid2obj(NID_X25519), V_ASN1_UNDEF,
                ^
109.                                   NULL, penc, X25519_KEYLEN)) {
110.           OPENSSL_free(penc);

crypto/ec/ecx_meth.c:114:5: 
112.           return 0;
113.       }
114. >     return 1;
115.   }
116.   

static int ecx_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
{
    const X25519_KEY *xkey = pkey->pkey.ptr;
    unsigned char *penc;
    if (xkey == NULL) {
        ECerr(EC_F_ECX_PUB_ENCODE, EC_R_INVALID_KEY);
        return 0;
    }
    penc = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);
    if (penc == NULL) {
        ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    if (!X509_PUBKEY_set0_param(pk, OBJ_nid2obj(NID_X25519), V_ASN1_UNDEF,
                                NULL, penc, X25519_KEYLEN)) {
        OPENSSL_free(penc);
        ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    return 1;
}
['static int ecx_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)\n{\n    const X25519_KEY *xkey = pkey->pkey.ptr;\n    unsigned char *penc;\n    if (xkey == NULL) {\n        ECerr(EC_F_ECX_PUB_ENCODE, EC_R_INVALID_KEY);\n        return 0;\n    }\n    penc = OPENSSL_memdup(xkey->pubkey, X25519_KEYLEN);\n    if (penc == NULL) {\n        ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    if (!X509_PUBKEY_set0_param(pk, OBJ_nid2obj(NID_X25519), V_ASN1_UNDEF,\n                                NULL, penc, X25519_KEYLEN)) {\n        OPENSSL_free(penc);\n        ECerr(EC_F_ECX_PUB_ENCODE, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    return 1;\n}', 'void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)\n{\n    void *ret;\n    if (data == NULL || siz >= INT_MAX)\n        return NULL;\n    ret = CRYPTO_malloc(siz, file, line);\n    if (ret == NULL) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return memcpy(ret, data, siz);\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    FAILTEST();\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}', 'ASN1_OBJECT *OBJ_nid2obj(int n)\n{\n    ADDED_OBJ ad, *adp;\n    ASN1_OBJECT ob;\n    if ((n >= 0) && (n < NUM_NID)) {\n        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {\n            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n        return ((ASN1_OBJECT *)&(nid_objs[n]));\n    } else if (added == NULL)\n        return (NULL);\n    else {\n        ad.type = ADDED_NID;\n        ad.obj = &ob;\n        ob.nid = n;\n        adp = lh_ADDED_OBJ_retrieve(added, &ad);\n        if (adp != NULL)\n            return (adp->obj);\n        else {\n            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n    }\n}']