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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
  204.           memset(ret, 0, num);
  205.       return ret;
  206. > }
  207.   
  208.   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:27:1: start of procedure CRYPTO_strdup()
  25.   }
  26.   
  27. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  28.   {
  29.       char *ret;

crypto/o_str.c:31:9: Taking false branch
  29.       char *ret;
  30.   
  31.       if (str == NULL)
                ^
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

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

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

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

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

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

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

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

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

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

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

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

crypto/o_str.c:34:9: Taking true branch
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
                ^
  35.           strcpy(ret, str);
  36.       return ret;

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

crypto/o_str.c:36:5: 
  34.       if (ret != NULL)
  35.           strcpy(ret, str);
  36. >     return ret;
  37.   }
  38.   

crypto/o_str.c:37:1: return from a call to CRYPTO_strdup
  35.           strcpy(ret, str);
  36.       return ret;
  37. > }
  38.   
  39.   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: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:265:1: start of procedure CRYPTO_free()
    263.   }
    264.   
    265. > void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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    (void)(file); (void)(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    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\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}']