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


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

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

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
  226.   }
  227.   
  228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  229.   {
  230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
  228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  229.   {
  230. >     void *ret = CRYPTO_malloc(num, file, line);
  231.   
  232.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking true branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
    208.            * allocation.
    209.            */
    210. >         allow_customize = 0;
    211.       }
    212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
  231.   
  232.       FAILTEST();
  233.       if (ret != NULL)
                 ^
  234.           memset(ret, 0, num);
  235.       return ret;

crypto/mem.c:234:9: 
  232.       FAILTEST();
  233.       if (ret != NULL)
  234. >         memset(ret, 0, num);
  235.       return ret;
  236.   }

crypto/mem.c:235:5: 
  233.       if (ret != NULL)
  234.           memset(ret, 0, num);
  235. >     return ret;
  236.   }
  237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
  234.           memset(ret, 0, num);
  235.       return ret;
  236. > }
  237.   
  238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

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

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

crypto/o_str.c:15:1: start of procedure CRYPTO_strdup()
  13.   #include "internal/cryptlib.h"
  14.   
  15. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  16.   {
  17.       char *ret;

crypto/o_str.c:19:9: Taking false branch
  17.       char *ret;
  18.   
  19.       if (str == NULL)
                ^
  20.           return NULL;
  21.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

crypto/o_str.c:21:5: 
  19.       if (str == NULL)
  20.           return NULL;
  21. >     ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  22.       if (ret != NULL)
  23.           strcpy(ret, str);

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking false branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:22:9: Taking true branch
  20.           return NULL;
  21.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  22.       if (ret != NULL)
                ^
  23.           strcpy(ret, str);
  24.       return ret;

crypto/o_str.c:23:9: 
  21.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  22.       if (ret != NULL)
  23. >         strcpy(ret, str);
  24.       return ret;
  25.   }

crypto/o_str.c:24:5: 
  22.       if (ret != NULL)
  23.           strcpy(ret, str);
  24. >     return ret;
  25.   }
  26.   

crypto/o_str.c:25:1: return from a call to CRYPTO_strdup
  23.           strcpy(ret, str);
  24.       return ret;
  25. > }
  26.   
  27.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

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

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

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:203:1: start of procedure i2d_PUBKEY()
    201.   }
    202.   
    203. > int i2d_PUBKEY(const EVP_PKEY *a, unsigned char **pp)
    204.   {
    205.       X509_PUBKEY *xpk = NULL;

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

crypto/x509/x_pubkey.c:206:5: 
    204.   {
    205.       X509_PUBKEY *xpk = NULL;
    206. >     int ret = -1;
    207.   
    208.       if (a == NULL)

crypto/x509/x_pubkey.c:208:9: Taking true branch
    206.       int ret = -1;
    207.   
    208.       if (a == NULL)
                   ^
    209.           return 0;
    210.       if ((xpk = X509_PUBKEY_new()) == NULL)

crypto/x509/x_pubkey.c:209:9: 
    207.   
    208.       if (a == NULL)
    209. >         return 0;
    210.       if ((xpk = X509_PUBKEY_new()) == NULL)
    211.           return -1;

crypto/x509/x_pubkey.c:221:1: return from a call to i2d_PUBKEY
    219.       X509_PUBKEY_free(xpk);
    220.       return ret;
    221. > }
    222.   
    223.   /*

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: 
  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.       }

providers/fips/fipsprov.c:316:1: start of procedure ERR_put_error()
    314.   }
    315.   
    316. > void ERR_put_error(int lib, int func, int reason, const char *file, int line)
    317.   {
    318.       /*

providers/fips/fipsprov.c:324:5: Skipping __function_pointer__(): unresolved function pointer
    322.        * so we'll need to come up with something else for them.
    323.        */
    324.       c_put_error(lib, func, reason, file, line);
               ^
    325.       ERR_add_error_data(1, "(in the FIPS module)");
    326.   }

providers/fips/fipsprov.c:325:5: Skipping ERR_add_error_data(): empty list of specs
    323.        */
    324.       c_put_error(lib, func, reason, file, line);
    325.       ERR_add_error_data(1, "(in the FIPS module)");
               ^
    326.   }
    327.   

providers/fips/fipsprov.c:326:1: return from a call to ERR_put_error
    324.       c_put_error(lib, func, reason, file, line);
    325.       ERR_add_error_data(1, "(in the FIPS module)");
    326. > }
    327.   
    328.   void ERR_add_error_data(int num, ...)

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:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking false branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:312:5: 
    310.       }
    311.   #else
    312. >     free(str);
    313.   #endif
    314.   }

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   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:252:9: Taking true branch
250.       }
251.   
252.       if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
               ^
253.           goto err;
254.   

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

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

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

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

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

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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

crypto/evp/p_lib.c:595:1: start of procedure EVP_PKEY_free()
    593.   }
    594.   
    595. > void EVP_PKEY_free(EVP_PKEY *x)
    596.   {
    597.       int i;

crypto/evp/p_lib.c:599:9: Taking true branch
    597.       int i;
    598.   
    599.       if (x == NULL)
                   ^
    600.           return;
    601.   

crypto/evp/p_lib.c:600:9: 
    598.   
    599.       if (x == NULL)
    600. >         return;
    601.   
    602.       CRYPTO_DOWN_REF(&x->references, &i, x->lock);

crypto/evp/p_lib.c:611:1: return from a call to EVP_PKEY_free
    609.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
    610.       OPENSSL_free(x);
    611. > }
    612.   
    613.   static void EVP_PKEY_free_it(EVP_PKEY *x)

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

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking false branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:312:5: 
    310.       }
    311.   #else
    312. >     free(str);
    313.   #endif
    314.   }

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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

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