crypto/x509/x509_cmp.c:268: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 252, column 26 is not reachable after line 268, column 5.
Showing all 58 steps of the trace


crypto/x509/x509_cmp.c:250:1: start of procedure X509_NAME_hash_old()
248.    */
249.   
250. > unsigned long X509_NAME_hash_old(X509_NAME *x)
251.   {
252.       EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();

crypto/x509/x509_cmp.c:252:5: 
250.   unsigned long X509_NAME_hash_old(X509_NAME *x)
251.   {
252. >     EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
253.       unsigned long ret = 0;
254.       unsigned char md[16];

crypto/evp/digest.c:145:1: start of procedure EVP_MD_CTX_new()
  143.   }
  144.   
  145. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  146.   {
  147.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:147:5: 
  145.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  146.   {
  147. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  148.   }
  149.   

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/evp/digest.c:148:1: return from a call to EVP_MD_CTX_new
  146.   {
  147.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  148. > }
  149.   
  150.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/x509/x509_cmp.c:253:5: 
251.   {
252.       EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
253. >     unsigned long ret = 0;
254.       unsigned char md[16];
255.   

crypto/x509/x509_cmp.c:256:9: Taking false branch
254.       unsigned char md[16];
255.   
256.       if (md_ctx == NULL)
               ^
257.           return ret;
258.   

crypto/x509/x509_cmp.c:260:5: 
258.   
259.       /* Make sure X509_NAME structure contains valid cached encoding */
260. >     i2d_X509_NAME(x, NULL);
261.       EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262.       if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)

crypto/x509/x_name.c:127:1: start of procedure i2d_X509_NAME()
  125.   IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff)
  126.   
  127. > IMPLEMENT_ASN1_FUNCTIONS(X509_NAME)
  128.   
  129.   IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)

crypto/asn1/tasn_enc.c:91:1: start of procedure ASN1_item_i2d()
    89.   }
    90.   
    91. > int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
    92.   {
    93.       return asn1_item_flags_i2d(val, out, it, 0);

crypto/asn1/tasn_enc.c:93:5: 
    91.   int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
    92.   {
    93. >     return asn1_item_flags_i2d(val, out, it, 0);
    94.   }
    95.   

crypto/asn1/tasn_enc.c:103:1: start of procedure asn1_item_flags_i2d()
      101.    */
      102.   
      103. > static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
      104.                                  const ASN1_ITEM *it, int flags)
      105.   {

crypto/asn1/tasn_enc.c:106:9: Taking false branch
      104.                                  const ASN1_ITEM *it, int flags)
      105.   {
      106.       if (out && !*out) {
                     ^
      107.           unsigned char *p, *buf;
      108.           int len;

crypto/asn1/tasn_enc.c:121:5: Skipping ASN1_item_ex_i2d(): empty list of specs
      119.       }
      120.   
      121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
                 ^
      122.   }
      123.   

crypto/asn1/tasn_enc.c:122:1: return from a call to asn1_item_flags_i2d
      120.   
      121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
      122. > }
      123.   
      124.   /*

crypto/asn1/tasn_enc.c:94:1: return from a call to ASN1_item_i2d
    92.   {
    93.       return asn1_item_flags_i2d(val, out, it, 0);
    94. > }
    95.   
    96.   /*

crypto/x509/x_name.c:127:1: return from a call to i2d_X509_NAME
  125.   IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff)
  126.   
  127. > IMPLEMENT_ASN1_FUNCTIONS(X509_NAME)
  128.   
  129.   IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)

crypto/x509/x509_cmp.c:261:5: 
259.       /* Make sure X509_NAME structure contains valid cached encoding */
260.       i2d_X509_NAME(x, NULL);
261. >     EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262.       if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
263.           && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)

crypto/evp/evp_lib.c:517:1: start of procedure EVP_MD_CTX_set_flags()
  515.   }
  516.   
  517. > void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
  518.   {
  519.       ctx->flags |= flags;

crypto/evp/evp_lib.c:519:5: 
  517.   void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
  518.   {
  519. >     ctx->flags |= flags;
  520.   }
  521.   

crypto/evp/evp_lib.c:520:1: return from a call to EVP_MD_CTX_set_flags
  518.   {
  519.       ctx->flags |= flags;
  520. > }
  521.   
  522.   void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags)

crypto/x509/x509_cmp.c:262:9: 
260.       i2d_X509_NAME(x, NULL);
261.       EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262. >     if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
263.           && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
264.           && EVP_DigestFinal_ex(md_ctx, md, NULL))

crypto/evp/m_md5.c:99:1: start of procedure EVP_md5()
  97.   };
  98.   
  99. > const EVP_MD *EVP_md5(void)
  100.   {
  101.       return (&md5_md);

crypto/evp/m_md5.c:101:5: 
  99.   const EVP_MD *EVP_md5(void)
  100.   {
  101. >     return (&md5_md);
  102.   }
  103.   #endif

crypto/evp/m_md5.c:102:1: return from a call to EVP_md5
  100.   {
  101.       return (&md5_md);
  102. > }
  103.   #endif

crypto/x509/x509_cmp.c:262:9: Taking true branch
260.       i2d_X509_NAME(x, NULL);
261.       EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262.       if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
               ^
263.           && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
264.           && EVP_DigestFinal_ex(md_ctx, md, NULL))

crypto/x509/x509_cmp.c:263:12: 
261.       EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262.       if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
263. >         && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
264.           && EVP_DigestFinal_ex(md_ctx, md, NULL))
265.           ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |

crypto/evp/digest.c:249:1: start of procedure EVP_DigestUpdate()
  247.   }
  248.   
  249. > int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  250.   {
  251.       return ctx->update(ctx, data, count);

crypto/evp/digest.c:251:5: Skipping __function_pointer__(): unresolved function pointer
  249.   int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  250.   {
  251.       return ctx->update(ctx, data, count);
             ^
  252.   }
  253.   

crypto/evp/digest.c:252:1: return from a call to EVP_DigestUpdate
  250.   {
  251.       return ctx->update(ctx, data, count);
  252. > }
  253.   
  254.   /* The caller can assume that this removes any secret data from the context */

crypto/x509/x509_cmp.c:263:12: Taking false branch
261.       EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
262.       if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
263.           && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
                  ^
264.           && EVP_DigestFinal_ex(md_ctx, md, NULL))
265.           ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |

crypto/x509/x509_cmp.c:268:5: 
266.                  ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
267.               ) & 0xffffffffL;
268. >     EVP_MD_CTX_free(md_ctx);
269.   
270.       return (ret);

crypto/evp/digest.c:150:1: start of procedure EVP_MD_CTX_free()
  148.   }
  149.   
  150. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  151.   {
  152.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:152:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  150.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  151.   {
  152.       EVP_MD_CTX_reset(ctx);
             ^
  153.       OPENSSL_free(ctx);
  154.   }

crypto/evp/digest.c:153:5: 
  151.   {
  152.       EVP_MD_CTX_reset(ctx);
  153. >     OPENSSL_free(ctx);
  154.   }
  155.   

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

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

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

crypto/mem.c:214:9: Skipping __function_pointer__(): unresolved function pointer
    212.   {
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    214.           free_impl(str, file, line);
                   ^
    215.           return;
    216.       }

crypto/mem.c:215:9: 
    213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    214.           free_impl(str, file, line);
    215. >         return;
    216.       }
    217.   

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

crypto/evp/digest.c:154:1: return from a call to EVP_MD_CTX_free
  152.       EVP_MD_CTX_reset(ctx);
  153.       OPENSSL_free(ctx);
  154. > }
  155.   
  156.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

unsigned long X509_NAME_hash_old(X509_NAME *x)
{
    EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
    unsigned long ret = 0;
    unsigned char md[16];
    if (md_ctx == NULL)
        return ret;
    i2d_X509_NAME(x, NULL);
    EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
    if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
        && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
        && EVP_DigestFinal_ex(md_ctx, md, NULL))
        ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
               ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
            ) & 0xffffffffL;
    EVP_MD_CTX_free(md_ctx);
    return (ret);
}
['unsigned long X509_NAME_hash_old(X509_NAME *x)\n{\n    EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();\n    unsigned long ret = 0;\n    unsigned char md[16];\n    if (md_ctx == NULL)\n        return ret;\n    i2d_X509_NAME(x, NULL);\n    EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);\n    if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)\n        && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)\n        && EVP_DigestFinal_ex(md_ctx, md, NULL))\n        ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |\n               ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)\n            ) & 0xffffffffL;\n    EVP_MD_CTX_free(md_ctx);\n    return (ret);\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\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}', 'IMPLEMENT_ASN1_FUNCTIONS(X509_NAME)', 'int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)\n{\n    return asn1_item_flags_i2d(val, out, it, 0);\n}', 'static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,\n                               const ASN1_ITEM *it, int flags)\n{\n    if (out && !*out) {\n        unsigned char *p, *buf;\n        int len;\n        len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags);\n        if (len <= 0)\n            return len;\n        buf = OPENSSL_malloc(len);\n        if (buf == NULL)\n            return -1;\n        p = buf;\n        ASN1_item_ex_i2d(&val, &p, it, -1, flags);\n        *out = buf;\n        return len;\n    }\n    return ASN1_item_ex_i2d(&val, out, it, -1, flags);\n}', 'void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)\n{\n    ctx->flags |= flags;\n}', 'const EVP_MD *EVP_md5(void)\n{\n    return (&md5_md);\n}', 'int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)\n{\n    return ctx->update(ctx, data, count);\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\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}']