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


test/evp_test.c:696:12: invalidation part of the trace starts here
694.       unsigned char md[EVP_MAX_MD_SIZE];
695.       unsigned int md_len;
696.       mctx = EVP_MD_CTX_new();
                  ^
697.       if (!mctx)
698.           goto err;

test/evp_test.c:696:12: passed as argument to `EVP_MD_CTX_new`
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
                    ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:696:12: return from call to `EVP_MD_CTX_new`
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
                    ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:696:5: assigned
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
             ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:700:10: when calling `EVP_DigestInit_ex` here
  698.           goto err;
  699.       err = "DIGESTINIT_ERROR";
  700.       if (!EVP_DigestInit_ex(mctx, mdata->digest, NULL))
                  ^
  701.           goto err;
  702.       err = "DIGESTUPDATE_ERROR";

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

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

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

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

test/evp_test.c:696:12: use-after-lifetime part of the trace starts here
694.       unsigned char md[EVP_MAX_MD_SIZE];
695.       unsigned int md_len;
696.       mctx = EVP_MD_CTX_new();
                  ^
697.       if (!mctx)
698.           goto err;

test/evp_test.c:696:12: passed as argument to `EVP_MD_CTX_new`
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
                    ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:696:12: return from call to `EVP_MD_CTX_new`
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
                    ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:696:5: assigned
  694.       unsigned char md[EVP_MAX_MD_SIZE];
  695.       unsigned int md_len;
  696.       mctx = EVP_MD_CTX_new();
             ^
  697.       if (!mctx)
  698.           goto err;

test/evp_test.c:708:10: when calling `EVP_DigestFinal` here
  706.       }
  707.       err = "DIGESTFINAL_ERROR";
  708.       if (!EVP_DigestFinal(mctx, md, &md_len))
                  ^
  709.           goto err;
  710.       err = "DIGEST_LENGTH_MISMATCH";

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

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