crypto/evp/digest.c:166: error: USE_AFTER_FREE
  call to `EVP_DigestInit_ex()` eventually accesses memory that was invalidated by call to `free()` on line 165 indirectly during the call to `EVP_MD_CTX_reset()`.
Showing all 16 steps of the trace


crypto/evp/digest.c:163:1: invalidation part of the trace starts here
161.   }
162.   
163. > int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
164.   {
165.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:163:1: parameter `ctx` of EVP_DigestInit
  161.   }
  162.   
  163. > int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
  164.   {
  165.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:165:5: when calling `EVP_MD_CTX_reset` here
  163.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
  164.   {
  165.       EVP_MD_CTX_reset(ctx);
             ^
  166.       return EVP_DigestInit_ex(ctx, type, NULL);
  167.   }

crypto/evp/digest.c:122:1: parameter `ctx` of EVP_MD_CTX_reset
    120.   
    121.   /* This call frees resources associated with the context */
    122. > int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
    123.   {
    124.       if (ctx == NULL)

crypto/evp/digest.c:136:9: when calling `CRYPTO_clear_free` here
    134.       if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
    135.           && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) {
    136.           OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);
                   ^
    137.       }
    138.       EVP_PKEY_CTX_free(ctx->pctx);

crypto/mem.c:248:1: parameter `str` of CRYPTO_clear_free
      246.   }
      247.   
      248. > void CRYPTO_clear_free(void *str, size_t num)
      249.   {
      250.       if (str == NULL)

crypto/mem.c:254:5: when calling `CRYPTO_free` here
      252.       if (num)
      253.           OPENSSL_cleanse(str, num);
      254.       CRYPTO_free(str);
                 ^
      255.   }

crypto/mem.c:233:1: parameter `str` of CRYPTO_free
        231.   }
        232.   
        233. > void CRYPTO_free(void *str)
        234.   {
        235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: was invalidated by call to `free()`
        242.       }
        243.   #else
        244.       free(str);
                   ^
        245.   #endif
        246.   }

crypto/evp/digest.c:163:1: use-after-lifetime part of the trace starts here
161.   }
162.   
163. > int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
164.   {
165.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:163:1: parameter `ctx` of EVP_DigestInit
  161.   }
  162.   
  163. > int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
  164.   {
  165.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:166:12: when calling `EVP_DigestInit_ex` here
  164.   {
  165.       EVP_MD_CTX_reset(ctx);
  166.       return EVP_DigestInit_ex(ctx, type, NULL);
                    ^
  167.   }
  168.   

crypto/evp/digest.c:169:1: parameter `ctx` of EVP_DigestInit_ex
    167.   }
    168.   
    169. > int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
    170.   {
    171.       EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);

crypto/evp/digest.c:228:13: when calling `CRYPTO_free` here
    226.       if (ctx->digest != type) {
    227.           if (ctx->digest && ctx->digest->ctx_size)
    228.               OPENSSL_free(ctx->md_data);
                       ^
    229.           ctx->digest = type;
    230.           if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size) {

crypto/mem.c:233:1: parameter `str` of CRYPTO_free
      231.   }
      232.   
      233. > void CRYPTO_free(void *str)
      234.   {
      235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: invalid access occurs here
      242.       }
      243.   #else
      244.       free(str);
                 ^
      245.   #endif
      246.   }
