test/evp_test.c:715: error: USE_AFTER_FREE
  call to `EVP_DigestFinal()` eventually accesses memory that was invalidated by call to `free()` on line 707 indirectly during the call to `EVP_DigestInit_ex()`.
Showing all 16 steps of the trace


test/evp_test.c:703:12: invalidation part of the trace starts here
701.       unsigned char md[EVP_MAX_MD_SIZE];
702.       unsigned int md_len;
703.       mctx = EVP_MD_CTX_new();
                  ^
704.       if (!mctx)
705.           goto err;

test/evp_test.c:703:12: passed as argument to `EVP_MD_CTX_new`
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
                    ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:703:12: return from call to `EVP_MD_CTX_new`
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
                    ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:703:5: assigned
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
             ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:707:10: when calling `EVP_DigestInit_ex` here
  705.           goto err;
  706.       err = "DIGESTINIT_ERROR";
  707.       if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL))
                  ^
  708.           goto err;
  709.       err = "DIGESTUPDATE_ERROR";

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: was invalidated by call to `free()`
      242.       }
      243.   #else
      244.       free(str);
                 ^
      245.   #endif
      246.   }

test/evp_test.c:703:12: use-after-lifetime part of the trace starts here
701.       unsigned char md[EVP_MAX_MD_SIZE];
702.       unsigned int md_len;
703.       mctx = EVP_MD_CTX_new();
                  ^
704.       if (!mctx)
705.           goto err;

test/evp_test.c:703:12: passed as argument to `EVP_MD_CTX_new`
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
                    ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:703:12: return from call to `EVP_MD_CTX_new`
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
                    ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:703:5: assigned
  701.       unsigned char md[EVP_MAX_MD_SIZE];
  702.       unsigned int md_len;
  703.       mctx = EVP_MD_CTX_new();
             ^
  704.       if (!mctx)
  705.           goto err;

test/evp_test.c:715:10: when calling `EVP_DigestFinal` here
  713.       }
  714.       err = "DIGESTFINAL_ERROR";
  715.       if (!EVP_DigestFinal(mctx, md, &md_len))
                  ^
  716.           goto err;
  717.       err = "DIGEST_LENGTH_MISMATCH";

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.   }
