crypto/ct/ct_log.c:292: error: MEMORY_LEAK
  memory dynamically allocated by call to `CTLOG_new_null()` at line 277, column 18 is not reachable after line 292, column 5.
Showing all 64 steps of the trace


crypto/ct/ct_log.c:275:1: start of procedure CTLOG_new()
273.    * Copies the name.
274.    */
275. > CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
276.   {
277.       CTLOG *ret = CTLOG_new_null();

crypto/ct/ct_log.c:277:5: 
275.   CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
276.   {
277. >     CTLOG *ret = CTLOG_new_null();
278.   
279.       if (ret == NULL)

crypto/ct/ct_log.c:296:1: start of procedure CTLOG_new_null()
  294.   }
  295.   
  296. > CTLOG *CTLOG_new_null(void)
  297.   {
  298.       CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));

crypto/ct/ct_log.c:298:5: 
  296.   CTLOG *CTLOG_new_null(void)
  297.   {
  298. >     CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));
  299.   
  300.       if (ret == NULL)

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:151:9: 
    149.   
    150.       if (ret != NULL)
    151. >         memset(ret, 0, num);
    152.       return ret;
    153.   }

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:300:9: Taking false branch
  298.       CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));
  299.   
  300.       if (ret == NULL)
                 ^
  301.           CTerr(CT_F_CTLOG_NEW_NULL, ERR_R_MALLOC_FAILURE);
  302.   

crypto/ct/ct_log.c:303:5: 
  301.           CTerr(CT_F_CTLOG_NEW_NULL, ERR_R_MALLOC_FAILURE);
  302.   
  303. >     return ret;
  304.   }
  305.   

crypto/ct/ct_log.c:304:1: return from a call to CTLOG_new_null
  302.   
  303.       return ret;
  304. > }
  305.   
  306.   /* Frees CT log and associated structures */

crypto/ct/ct_log.c:279:9: Taking false branch
277.       CTLOG *ret = CTLOG_new_null();
278.   
279.       if (ret == NULL)
               ^
280.           goto err;
281.   

crypto/ct/ct_log.c:282:5: 
280.           goto err;
281.   
282. >     ret->name = OPENSSL_strdup(name);
283.       if (ret->name == NULL)
284.           goto err;

crypto/o_str.c:120:1: start of procedure CRYPTO_strdup()
  118.   }
  119.   
  120. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  121.   {
  122.       char *ret;

crypto/o_str.c:125:9: Taking false branch
  123.       size_t size;
  124.   
  125.       if (str == NULL)
                 ^
  126.           return NULL;
  127.       size = strlen(str) + 1;

crypto/o_str.c:127:5: 
  125.       if (str == NULL)
  126.           return NULL;
  127. >     size = strlen(str) + 1;
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)

crypto/o_str.c:128:5: 
  126.           return NULL;
  127.       size = strlen(str) + 1;
  128. >     ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
  130.           memcpy(ret, str, size);

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking true branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:123:32: Taking true branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:124:9: Skipping __function_pointer__(): unresolved function pointer
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
    124.           return malloc_impl(num, file, line);
                   ^
    125.   
    126.       if (num <= 0)

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
    142.   
    143.       return ret;
    144. > }
    145.   
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:129:9: Taking true branch
  127.       size = strlen(str) + 1;
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
                 ^
  130.           memcpy(ret, str, size);
  131.       return ret;

crypto/o_str.c:130:9: 
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
  130. >         memcpy(ret, str, size);
  131.       return ret;
  132.   }

crypto/o_str.c:131:5: 
  129.       if (ret != NULL)
  130.           memcpy(ret, str, size);
  131. >     return ret;
  132.   }
  133.   

crypto/o_str.c:132:1: return from a call to CRYPTO_strdup
  130.           memcpy(ret, str, size);
  131.       return ret;
  132. > }
  133.   
  134.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/ct/ct_log.c:283:9: Taking false branch
281.   
282.       ret->name = OPENSSL_strdup(name);
283.       if (ret->name == NULL)
               ^
284.           goto err;
285.   

crypto/ct/ct_log.c:286:5: 
284.           goto err;
285.   
286. >     ret->public_key = public_key;
287.       if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
288.           goto err;

crypto/ct/ct_log.c:287:9: 
285.   
286.       ret->public_key = public_key;
287. >     if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
288.           goto err;
289.   

crypto/ct/ct_log.c:124:1: start of procedure ct_v1_log_id_from_pkey()
  122.   
  123.   /* Converts a log's public key into a SHA256 log ID */
  124. > static int ct_v1_log_id_from_pkey(EVP_PKEY *pkey,
  125.                                     unsigned char log_id[CT_V1_HASHLEN])
  126.   {

crypto/ct/ct_log.c:127:5: 
  125.                                     unsigned char log_id[CT_V1_HASHLEN])
  126.   {
  127. >     int ret = 0;
  128.       unsigned char *pkey_der = NULL;
  129.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);

crypto/ct/ct_log.c:128:5: 
  126.   {
  127.       int ret = 0;
  128. >     unsigned char *pkey_der = NULL;
  129.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  130.   

crypto/ct/ct_log.c:129:5: 
  127.       int ret = 0;
  128.       unsigned char *pkey_der = NULL;
  129. >     int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  130.   
  131.       if (pkey_der_len <= 0) {

crypto/asn1/x_pubkey.c:216:1: start of procedure i2d_PUBKEY()
    214.   }
    215.   
    216. > int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
    217.   {
    218.       X509_PUBKEY *xpk = NULL;

crypto/asn1/x_pubkey.c:218:5: 
    216.   int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
    217.   {
    218. >     X509_PUBKEY *xpk = NULL;
    219.       int ret;
    220.       if (!a)

crypto/asn1/x_pubkey.c:220:10: Taking true branch
    218.       X509_PUBKEY *xpk = NULL;
    219.       int ret;
    220.       if (!a)
                    ^
    221.           return 0;
    222.       if (!X509_PUBKEY_set(&xpk, a))

crypto/asn1/x_pubkey.c:221:9: 
    219.       int ret;
    220.       if (!a)
    221. >         return 0;
    222.       if (!X509_PUBKEY_set(&xpk, a))
    223.           return 0;

crypto/asn1/x_pubkey.c:227:1: return from a call to i2d_PUBKEY
    225.       X509_PUBKEY_free(xpk);
    226.       return ret;
    227. > }
    228.   
    229.   /*

crypto/ct/ct_log.c:131:9: Taking true branch
  129.       int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);
  130.   
  131.       if (pkey_der_len <= 0) {
                 ^
  132.           CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);
  133.           goto err;

crypto/ct/ct_log.c:132:9: Skipping ERR_put_error(): empty list of specs
  130.   
  131.       if (pkey_der_len <= 0) {
  132.           CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);
                 ^
  133.           goto err;
  134.       }

crypto/ct/ct_log.c:138:1: 
  136.       SHA256(pkey_der, pkey_der_len, log_id);
  137.       ret = 1;
  138. > err:
  139.       OPENSSL_free(pkey_der);
  140.       return ret;

crypto/ct/ct_log.c:139:5: 
  137.       ret = 1;
  138.   err:
  139. >     OPENSSL_free(pkey_der);
  140.       return ret;
  141.   }

crypto/mem.c:210:1: start of procedure CRYPTO_free()
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:212:9: Taking false branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:226:5: 
    224.       }
    225.   #else
    226. >     free(str);
    227.   #endif
    228.   }

crypto/mem.c:228:1: return from a call to CRYPTO_free
    226.       free(str);
    227.   #endif
    228. > }
    229.   
    230.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:140:5: 
  138.   err:
  139.       OPENSSL_free(pkey_der);
  140. >     return ret;
  141.   }
  142.   

crypto/ct/ct_log.c:141:1: return from a call to ct_v1_log_id_from_pkey
  139.       OPENSSL_free(pkey_der);
  140.       return ret;
  141. > }
  142.   
  143.   CTLOG_STORE *CTLOG_STORE_new(void)

crypto/ct/ct_log.c:287:9: Taking true branch
285.   
286.       ret->public_key = public_key;
287.       if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
               ^
288.           goto err;
289.   

crypto/ct/ct_log.c:291:1: 
289.   
290.       return ret;
291. > err:
292.       CTLOG_free(ret);
293.       return NULL;

crypto/ct/ct_log.c:292:5: Skipping CTLOG_free(): empty list of specs
290.       return ret;
291.   err:
292.       CTLOG_free(ret);
           ^
293.       return NULL;
294.   }

CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
{
    CTLOG *ret = CTLOG_new_null();
    if (ret == NULL)
        goto err;
    ret->name = OPENSSL_strdup(name);
    if (ret->name == NULL)
        goto err;
    ret->public_key = public_key;
    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
        goto err;
    return ret;
err:
    CTLOG_free(ret);
    return NULL;
}
['CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)\n{\n    CTLOG *ret = CTLOG_new_null();\n    if (ret == NULL)\n        goto err;\n    ret->name = OPENSSL_strdup(name);\n    if (ret->name == NULL)\n        goto err;\n    ret->public_key = public_key;\n    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)\n        goto err;\n    return ret;\nerr:\n    CTLOG_free(ret);\n    return NULL;\n}', 'CTLOG *CTLOG_new_null(void)\n{\n    CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL)\n        CTerr(CT_F_CTLOG_NEW_NULL, ERR_R_MALLOC_FAILURE);\n    return ret;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\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    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}']