crypto/ct/ct_log.c:256: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_strdup()` at line 244, column 17 is not reachable after line 256, column 5.
Showing all 83 steps of the trace


crypto/ct/ct_log.c:235:1: start of procedure CTLOG_new()
233.    * Copies the name.
234.    */
235. > CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
236.   {
237.       CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));

crypto/ct/ct_log.c:237:5: 
235.   CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
236.   {
237. >     CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));
238.   
239.       if (ret == NULL) {

crypto/mem.c:185:1: start of procedure CRYPTO_zalloc()
  183.   }
  184.   
  185. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  186.   {
  187.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:187:5: 
  185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  186.   {
  187. >     void *ret = CRYPTO_malloc(num, file, line);
  188.   
  189.       FAILTEST();

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/mem.c:190:9: Taking true branch
  188.   
  189.       FAILTEST();
  190.       if (ret != NULL)
                 ^
  191.           memset(ret, 0, num);
  192.       return ret;

crypto/mem.c:191:9: 
  189.       FAILTEST();
  190.       if (ret != NULL)
  191. >         memset(ret, 0, num);
  192.       return ret;
  193.   }

crypto/mem.c:192:5: 
  190.       if (ret != NULL)
  191.           memset(ret, 0, num);
  192. >     return ret;
  193.   }
  194.   

crypto/mem.c:193:1: return from a call to CRYPTO_zalloc
  191.           memset(ret, 0, num);
  192.       return ret;
  193. > }
  194.   
  195.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:239:9: Taking false branch
237.       CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));
238.   
239.       if (ret == NULL) {
               ^
240.           CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);
241.           return NULL;

crypto/ct/ct_log.c:244:5: 
242.       }
243.   
244. >     ret->name = OPENSSL_strdup(name);
245.       if (ret->name == NULL) {
246.           CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);

crypto/o_str.c:28:1: start of procedure CRYPTO_strdup()
  26.   }
  27.   
  28. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  29.   {
  30.       char *ret;

crypto/o_str.c:33:9: Taking false branch
  31.       size_t size;
  32.   
  33.       if (str == NULL)
                ^
  34.           return NULL;
  35.       size = strlen(str) + 1;

crypto/o_str.c:35:5: 
  33.       if (str == NULL)
  34.           return NULL;
  35. >     size = strlen(str) + 1;
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)

crypto/o_str.c:36:5: 
  34.           return NULL;
  35.       size = strlen(str) + 1;
  36. >     ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);

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:37:9: Taking true branch
  35.       size = strlen(str) + 1;
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
                ^
  38.           memcpy(ret, str, size);
  39.       return ret;

crypto/o_str.c:38:9: 
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38. >         memcpy(ret, str, size);
  39.       return ret;
  40.   }

crypto/o_str.c:39:5: 
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);
  39. >     return ret;
  40.   }
  41.   

crypto/o_str.c:40:1: return from a call to CRYPTO_strdup
  38.           memcpy(ret, str, size);
  39.       return ret;
  40. > }
  41.   
  42.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/ct/ct_log.c:245:9: Taking false branch
243.   
244.       ret->name = OPENSSL_strdup(name);
245.       if (ret->name == NULL) {
               ^
246.           CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);
247.           goto err;

crypto/ct/ct_log.c:250:9: 
248.       }
249.   
250. >     if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
251.           goto err;
252.   

crypto/ct/ct_log.c:73:1: start of procedure ct_v1_log_id_from_pkey()
  71.   
  72.   /* Converts a log's public key into a SHA256 log ID */
  73. > static int ct_v1_log_id_from_pkey(EVP_PKEY *pkey,
  74.                                     unsigned char log_id[CT_V1_HASHLEN])
  75.   {

crypto/ct/ct_log.c:76:5: 
  74.                                     unsigned char log_id[CT_V1_HASHLEN])
  75.   {
  76. >     int ret = 0;
  77.       unsigned char *pkey_der = NULL;
  78.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);

crypto/ct/ct_log.c:77:5: 
  75.   {
  76.       int ret = 0;
  77. >     unsigned char *pkey_der = NULL;
  78.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  79.   

crypto/ct/ct_log.c:78:5: 
  76.       int ret = 0;
  77.       unsigned char *pkey_der = NULL;
  78. >     int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  79.   
  80.       if (pkey_der_len <= 0) {

crypto/x509/x_pubkey.c:202:1: start of procedure i2d_PUBKEY()
    200.   }
    201.   
    202. > int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
    203.   {
    204.       X509_PUBKEY *xpk = NULL;

crypto/x509/x_pubkey.c:204:5: 
    202.   int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
    203.   {
    204. >     X509_PUBKEY *xpk = NULL;
    205.       int ret;
    206.       if (!a)

crypto/x509/x_pubkey.c:206:10: Taking true branch
    204.       X509_PUBKEY *xpk = NULL;
    205.       int ret;
    206.       if (!a)
                    ^
    207.           return 0;
    208.       if (!X509_PUBKEY_set(&xpk, a))

crypto/x509/x_pubkey.c:207:9: 
    205.       int ret;
    206.       if (!a)
    207. >         return 0;
    208.       if (!X509_PUBKEY_set(&xpk, a))
    209.           return 0;

crypto/x509/x_pubkey.c:213:1: return from a call to i2d_PUBKEY
    211.       X509_PUBKEY_free(xpk);
    212.       return ret;
    213. > }
    214.   
    215.   /*

crypto/ct/ct_log.c:80:9: Taking true branch
  78.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  79.   
  80.       if (pkey_der_len <= 0) {
                ^
  81.           CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);
  82.           goto err;

crypto/ct/ct_log.c:81:9: Skipping ERR_put_error(): empty list of specs
  79.   
  80.       if (pkey_der_len <= 0) {
  81.           CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);
                ^
  82.           goto err;
  83.       }

crypto/ct/ct_log.c:87:1: 
  85.       SHA256(pkey_der, pkey_der_len, log_id);
  86.       ret = 1;
  87. > err:
  88.       OPENSSL_free(pkey_der);
  89.       return ret;

crypto/ct/ct_log.c:88:5: 
  86.       ret = 1;
  87.   err:
  88. >     OPENSSL_free(pkey_der);
  89.       return ret;
  90.   }

crypto/mem.c:252:1: start of procedure CRYPTO_free()
    250.   }
    251.   
    252. > void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:254:9: Taking false branch
    252.   void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    255.           free_impl(str, file, line);
    256.           return;

crypto/mem.c:268:5: 
    266.       }
    267.   #else
    268. >     free(str);
    269.   #endif
    270.   }

crypto/mem.c:270:1: return from a call to CRYPTO_free
    268.       free(str);
    269.   #endif
    270. > }
    271.   
    272.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:89:5: 
  87.   err:
  88.       OPENSSL_free(pkey_der);
  89. >     return ret;
  90.   }
  91.   

crypto/ct/ct_log.c:90:1: return from a call to ct_v1_log_id_from_pkey
  88.       OPENSSL_free(pkey_der);
  89.       return ret;
  90. > }
  91.   
  92.   CTLOG_STORE *CTLOG_STORE_new(void)

crypto/ct/ct_log.c:250:9: Taking true branch
248.       }
249.   
250.       if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
               ^
251.           goto err;
252.   

crypto/ct/ct_log.c:255:1: 
253.       ret->public_key = public_key;
254.       return ret;
255. > err:
256.       CTLOG_free(ret);
257.       return NULL;

crypto/ct/ct_log.c:256:5: 
254.       return ret;
255.   err:
256. >     CTLOG_free(ret);
257.       return NULL;
258.   }

crypto/ct/ct_log.c:261:1: start of procedure CTLOG_free()
  259.   
  260.   /* Frees CT log and associated structures */
  261. > void CTLOG_free(CTLOG *log)
  262.   {
  263.       if (log != NULL) {

crypto/ct/ct_log.c:263:9: Taking true branch
  261.   void CTLOG_free(CTLOG *log)
  262.   {
  263.       if (log != NULL) {
                 ^
  264.           OPENSSL_free(log->name);
  265.           EVP_PKEY_free(log->public_key);

crypto/ct/ct_log.c:264:9: 
  262.   {
  263.       if (log != NULL) {
  264. >         OPENSSL_free(log->name);
  265.           EVP_PKEY_free(log->public_key);
  266.           OPENSSL_free(log);

crypto/mem.c:252:1: start of procedure CRYPTO_free()
    250.   }
    251.   
    252. > void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:254:9: Taking true branch
    252.   void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    255.           free_impl(str, file, line);
    256.           return;

crypto/mem.c:254:30: Taking true branch
    252.   void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    255.           free_impl(str, file, line);
    256.           return;

crypto/mem.c:255:9: Skipping __function_pointer__(): unresolved function pointer
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    255.           free_impl(str, file, line);
                   ^
    256.           return;
    257.       }

crypto/mem.c:256:9: 
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    255.           free_impl(str, file, line);
    256. >         return;
    257.       }
    258.   

crypto/mem.c:270:1: return from a call to CRYPTO_free
    268.       free(str);
    269.   #endif
    270. > }
    271.   
    272.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:265:9: 
  263.       if (log != NULL) {
  264.           OPENSSL_free(log->name);
  265. >         EVP_PKEY_free(log->public_key);
  266.           OPENSSL_free(log);
  267.       }

crypto/evp/p_lib.c:388:1: start of procedure EVP_PKEY_free()
    386.   }
    387.   
    388. > void EVP_PKEY_free(EVP_PKEY *x)
    389.   {
    390.       int i;

crypto/evp/p_lib.c:392:9: Taking true branch
    390.       int i;
    391.   
    392.       if (x == NULL)
                   ^
    393.           return;
    394.   

crypto/evp/p_lib.c:393:9: 
    391.   
    392.       if (x == NULL)
    393. >         return;
    394.   
    395.       CRYPTO_DOWN_REF(&x->references, &i, x->lock);

crypto/evp/p_lib.c:404:1: return from a call to EVP_PKEY_free
    402.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
    403.       OPENSSL_free(x);
    404. > }
    405.   
    406.   static void EVP_PKEY_free_it(EVP_PKEY *x)

crypto/ct/ct_log.c:266:9: 
  264.           OPENSSL_free(log->name);
  265.           EVP_PKEY_free(log->public_key);
  266. >         OPENSSL_free(log);
  267.       }
  268.   }

crypto/mem.c:252:1: start of procedure CRYPTO_free()
    250.   }
    251.   
    252. > void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:254:9: Taking false branch
    252.   void CRYPTO_free(void *str, const char *file, int line)
    253.   {
    254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    255.           free_impl(str, file, line);
    256.           return;

crypto/mem.c:268:5: 
    266.       }
    267.   #else
    268. >     free(str);
    269.   #endif
    270.   }

crypto/mem.c:270:1: return from a call to CRYPTO_free
    268.       free(str);
    269.   #endif
    270. > }
    271.   
    272.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:263:5: 
  261.   void CTLOG_free(CTLOG *log)
  262.   {
  263. >     if (log != NULL) {
  264.           OPENSSL_free(log->name);
  265.           EVP_PKEY_free(log->public_key);

crypto/ct/ct_log.c:268:1: return from a call to CTLOG_free
  266.           OPENSSL_free(log);
  267.       }
  268. > }
  269.   
  270.   const char *CTLOG_get0_name(const CTLOG *log)

CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
{
    CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));
    if (ret == NULL) {
        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    ret->name = OPENSSL_strdup(name);
    if (ret->name == NULL) {
        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
        goto err;
    ret->public_key = public_key;
    return ret;
err:
    CTLOG_free(ret);
    return NULL;
}
['CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)\n{\n    CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->name = OPENSSL_strdup(name);\n    if (ret->name == NULL) {\n        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)\n        goto err;\n    ret->public_key = public_key;\n    return ret;\nerr:\n    CTLOG_free(ret);\n    return NULL;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\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}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    size_t size;\n    if (str == NULL)\n        return NULL;\n    size = strlen(str) + 1;\n    ret = CRYPTO_malloc(size, file, line);\n    if (ret != NULL)\n        memcpy(ret, str, size);\n    return ret;\n}', 'static int ct_v1_log_id_from_pkey(EVP_PKEY *pkey,\n                                  unsigned char log_id[CT_V1_HASHLEN])\n{\n    int ret = 0;\n    unsigned char *pkey_der = NULL;\n    int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);\n    if (pkey_der_len <= 0) {\n        CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);\n        goto err;\n    }\n    SHA256(pkey_der, pkey_der_len, log_id);\n    ret = 1;\nerr:\n    OPENSSL_free(pkey_der);\n    return ret;\n}', 'int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)\n{\n    X509_PUBKEY *xpk = NULL;\n    int ret;\n    if (!a)\n        return 0;\n    if (!X509_PUBKEY_set(&xpk, a))\n        return 0;\n    ret = i2d_X509_PUBKEY(xpk, pp);\n    X509_PUBKEY_free(xpk);\n    return ret;\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'void CTLOG_free(CTLOG *log)\n{\n    if (log != NULL) {\n        OPENSSL_free(log->name);\n        EVP_PKEY_free(log->public_key);\n        OPENSSL_free(log);\n    }\n}', 'void EVP_PKEY_free(EVP_PKEY *x)\n{\n    int i;\n    if (x == NULL)\n        return;\n    CRYPTO_DOWN_REF(&x->references, &i, x->lock);\n    REF_PRINT_COUNT("EVP_PKEY", x);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    EVP_PKEY_free_it(x);\n    CRYPTO_THREAD_lock_free(x->lock);\n    sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);\n    OPENSSL_free(x);\n}']