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 99 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:197:1: start of procedure CRYPTO_zalloc()
  195.   }
  196.   
  197. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  198.   {
  199.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:199:5: 
  197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  198.   {
  199. >     void *ret = CRYPTO_malloc(num, file, line);
  200.   
  201.       FAILTEST();

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
    167.   #endif
    168.   
    169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    170.   {
    171.       void *ret = NULL;

crypto/mem.c:171:5: 
    169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    170.   {
    171. >     void *ret = NULL;
    172.   
    173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking false branch
    171.       void *ret = NULL;
    172.   
    173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    174.           return malloc_impl(num, file, line);
    175.   

crypto/mem.c:176:9: Taking false branch
    174.           return malloc_impl(num, file, line);
    175.   
    176.       if (num == 0)
                   ^
    177.           return NULL;
    178.   

crypto/mem.c:180:5: 
    178.   
    179.       FAILTEST();
    180. >     allow_customize = 0;
    181.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    182.       if (call_malloc_debug) {

crypto/mem.c:190:5: 
    188.       }
    189.   #else
    190. >     osslargused(file); osslargused(line);
    191.       ret = malloc(num);
    192.   #endif

crypto/mem.c:190:24: 
    188.       }
    189.   #else
    190. >     osslargused(file); osslargused(line);
    191.       ret = malloc(num);
    192.   #endif

crypto/mem.c:191:5: 
    189.   #else
    190.       osslargused(file); osslargused(line);
    191. >     ret = malloc(num);
    192.   #endif
    193.   

crypto/mem.c:194:5: 
    192.   #endif
    193.   
    194. >     return ret;
    195.   }
    196.   

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
    193.   
    194.       return ret;
    195. > }
    196.   
    197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:202:9: Taking true branch
  200.   
  201.       FAILTEST();
  202.       if (ret != NULL)
                 ^
  203.           memset(ret, 0, num);
  204.       return ret;

crypto/mem.c:203:9: 
  201.       FAILTEST();
  202.       if (ret != NULL)
  203. >         memset(ret, 0, num);
  204.       return ret;
  205.   }

crypto/mem.c:204:5: 
  202.       if (ret != NULL)
  203.           memset(ret, 0, num);
  204. >     return ret;
  205.   }
  206.   

crypto/mem.c:205:1: return from a call to CRYPTO_zalloc
  203.           memset(ret, 0, num);
  204.       return ret;
  205. > }
  206.   
  207.   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:169:1: start of procedure CRYPTO_malloc()
    167.   #endif
    168.   
    169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    170.   {
    171.       void *ret = NULL;

crypto/mem.c:171:5: 
    169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    170.   {
    171. >     void *ret = NULL;
    172.   
    173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking false branch
    171.       void *ret = NULL;
    172.   
    173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    174.           return malloc_impl(num, file, line);
    175.   

crypto/mem.c:176:9: Taking false branch
    174.           return malloc_impl(num, file, line);
    175.   
    176.       if (num == 0)
                   ^
    177.           return NULL;
    178.   

crypto/mem.c:180:5: 
    178.   
    179.       FAILTEST();
    180. >     allow_customize = 0;
    181.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    182.       if (call_malloc_debug) {

crypto/mem.c:190:5: 
    188.       }
    189.   #else
    190. >     osslargused(file); osslargused(line);
    191.       ret = malloc(num);
    192.   #endif

crypto/mem.c:190:24: 
    188.       }
    189.   #else
    190. >     osslargused(file); osslargused(line);
    191.       ret = malloc(num);
    192.   #endif

crypto/mem.c:191:5: 
    189.   #else
    190.       osslargused(file); osslargused(line);
    191. >     ret = malloc(num);
    192.   #endif
    193.   

crypto/mem.c:194:5: 
    192.   #endif
    193.   
    194. >     return ret;
    195.   }
    196.   

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
    193.   
    194.       return ret;
    195. > }
    196.   
    197.   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: 
  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/err/err.c:365:1: start of procedure ERR_put_error()
    363.   /********************************************************/
    364.   
    365. > void ERR_put_error(int lib, int func, int reason, const char *file, int line)
    366.   {
    367.       ERR_STATE *es;

crypto/err/err.c:388:5: 
    386.       }
    387.   #endif
    388. >     es = ERR_get_state();
    389.       if (es == NULL)
    390.           return;

crypto/err/err.c:679:1: start of procedure ERR_get_state()
      677.   }
      678.   
      679. > ERR_STATE *ERR_get_state(void)
      680.   {
      681.       ERR_STATE *state = NULL;

crypto/err/err.c:681:5: 
      679.   ERR_STATE *ERR_get_state(void)
      680.   {
      681. >     ERR_STATE *state = NULL;
      682.   
      683.       if (!RUN_ONCE(&err_init, err_do_init))

crypto/err/err.c:683:10: 
      681.       ERR_STATE *state = NULL;
      682.   
      683. >     if (!RUN_ONCE(&err_init, err_do_init))
      684.           return NULL;
      685.   

crypto/threads_pthread.c:105:1: start of procedure CRYPTO_THREAD_run_once()
        103.   }
        104.   
        105. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
        106.   {
        107.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:107:9: Taking true branch
        105.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
        106.   {
        107.       if (pthread_once(once, init) != 0)
                       ^
        108.           return 0;
        109.   

crypto/threads_pthread.c:108:9: 
        106.   {
        107.       if (pthread_once(once, init) != 0)
        108. >         return 0;
        109.   
        110.       return 1;

crypto/threads_pthread.c:111:1: return from a call to CRYPTO_THREAD_run_once
        109.   
        110.       return 1;
        111. > }
        112.   
        113.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/err/err.c:683:10: Condition is false
      681.       ERR_STATE *state = NULL;
      682.   
      683.       if (!RUN_ONCE(&err_init, err_do_init))
                      ^
      684.           return NULL;
      685.   

crypto/err/err.c:683:10: Taking true branch
      681.       ERR_STATE *state = NULL;
      682.   
      683.       if (!RUN_ONCE(&err_init, err_do_init))
                      ^
      684.           return NULL;
      685.   

crypto/err/err.c:684:9: 
      682.   
      683.       if (!RUN_ONCE(&err_init, err_do_init))
      684. >         return NULL;
      685.   
      686.       state = CRYPTO_THREAD_get_local(&err_thread_local);

crypto/err/err.c:704:1: return from a call to ERR_get_state
      702.   
      703.       return state;
      704. > }
      705.   
      706.   int ERR_get_next_error_library(void)

crypto/err/err.c:389:9: Taking true branch
    387.   #endif
    388.       es = ERR_get_state();
    389.       if (es == NULL)
                   ^
    390.           return;
    391.   

crypto/err/err.c:390:9: 
    388.       es = ERR_get_state();
    389.       if (es == NULL)
    390. >         return;
    391.   
    392.       es->top = (es->top + 1) % ERR_NUM_ERRORS;

crypto/err/err.c:400:1: return from a call to ERR_put_error
    398.       es->err_line[es->top] = line;
    399.       err_clear_data(es, es->top);
    400. > }
    401.   
    402.   void ERR_clear_error(void)

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:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:266:9: Taking false branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:280:5: 
    278.       }
    279.   #else
    280. >     free(str);
    281.   #endif
    282.   }

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   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:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:266:9: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:266:30: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:267:9: Skipping __function_pointer__(): unresolved function pointer
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
                   ^
    268.           return;
    269.       }

crypto/mem.c:268:9: 
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
    268. >         return;
    269.       }
    270.   

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   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:417:1: start of procedure EVP_PKEY_free()
    415.   }
    416.   
    417. > void EVP_PKEY_free(EVP_PKEY *x)
    418.   {
    419.       int i;

crypto/evp/p_lib.c:421:9: Taking true branch
    419.       int i;
    420.   
    421.       if (x == NULL)
                   ^
    422.           return;
    423.   

crypto/evp/p_lib.c:422:9: 
    420.   
    421.       if (x == NULL)
    422. >         return;
    423.   
    424.       CRYPTO_DOWN_REF(&x->references, &i, x->lock);

crypto/evp/p_lib.c:433:1: return from a call to EVP_PKEY_free
    431.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
    432.       OPENSSL_free(x);
    433. > }
    434.   
    435.   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:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:266:9: Taking false branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:280:5: 
    278.       }
    279.   #else
    280. >     free(str);
    281.   #endif
    282.   }

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   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)
