crypto/hmac/hmac.c:232: error: USE_AFTER_FREE
  call to `EVP_MD_CTX_copy_ex()` eventually accesses memory that was invalidated by call to `free()` on line 230 indirectly during the call to `HMAC_CTX_reset()`.
Showing all 18 steps of the trace


crypto/hmac/hmac.c:228:1: invalidation part of the trace starts here
226.   }
227.   
228. > int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
229.   {
230.       if (!HMAC_CTX_reset(dctx))

crypto/hmac/hmac.c:228:1: parameter `dctx` of HMAC_CTX_copy
  226.   }
  227.   
  228. > int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
  229.   {
  230.       if (!HMAC_CTX_reset(dctx))

crypto/hmac/hmac.c:230:10: when calling `HMAC_CTX_reset` here
  228.   int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
  229.   {
  230.       if (!HMAC_CTX_reset(dctx))
                  ^
  231.           goto err;
  232.       if (!EVP_MD_CTX_copy_ex(dctx->i_ctx, sctx->i_ctx))

crypto/hmac/hmac.c:206:1: parameter `ctx` of HMAC_CTX_reset
    204.   }
    205.   
    206. > int HMAC_CTX_reset(HMAC_CTX *ctx)
    207.   {
    208.       hmac_ctx_cleanup(ctx);

crypto/hmac/hmac.c:208:5: when calling `hmac_ctx_cleanup` here
    206.   int HMAC_CTX_reset(HMAC_CTX *ctx)
    207.   {
    208.       hmac_ctx_cleanup(ctx);
               ^
    209.       if (ctx->i_ctx == NULL)
    210.           ctx->i_ctx = EVP_MD_CTX_new();

crypto/hmac/hmac.c:185:1: parameter `ctx` of hmac_ctx_cleanup
      183.   }
      184.   
      185. > static void hmac_ctx_cleanup(HMAC_CTX *ctx)
      186.   {
      187.       EVP_MD_CTX_reset(ctx->i_ctx);

crypto/hmac/hmac.c:187:5: when calling `EVP_MD_CTX_reset` here
      185.   static void hmac_ctx_cleanup(HMAC_CTX *ctx)
      186.   {
      187.       EVP_MD_CTX_reset(ctx->i_ctx);
                 ^
      188.       EVP_MD_CTX_reset(ctx->o_ctx);
      189.       EVP_MD_CTX_reset(ctx->md_ctx);

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:138:5: when calling `EVP_PKEY_CTX_free` here
        136.           OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);
        137.       }
        138.       EVP_PKEY_CTX_free(ctx->pctx);
                   ^
        139.   #ifndef OPENSSL_NO_ENGINE
        140.       if (ctx->engine)

crypto/evp/pmeth_lib.c:323:1: parameter `ctx` of EVP_PKEY_CTX_free
          321.   }
          322.   
          323. > void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)
          324.   {
          325.       if (ctx == NULL)

crypto/evp/pmeth_lib.c:339:5: when calling `CRYPTO_free` here
          337.           ENGINE_finish(ctx->engine);
          338.   #endif
          339.       OPENSSL_free(ctx);
                     ^
          340.   }
          341.   

crypto/mem.c:225:1: parameter `str` of CRYPTO_free
            223.   }
            224.   
            225. > void CRYPTO_free(void *str, const char *file, int line)
            226.   {
            227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

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

crypto/hmac/hmac.c:228:1: use-after-lifetime part of the trace starts here
226.   }
227.   
228. > int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
229.   {
230.       if (!HMAC_CTX_reset(dctx))

crypto/hmac/hmac.c:228:1: parameter `dctx` of HMAC_CTX_copy
  226.   }
  227.   
  228. > int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx)
  229.   {
  230.       if (!HMAC_CTX_reset(dctx))

crypto/hmac/hmac.c:232:10: when calling `EVP_MD_CTX_copy_ex` here
  230.       if (!HMAC_CTX_reset(dctx))
  231.           goto err;
  232.       if (!EVP_MD_CTX_copy_ex(dctx->i_ctx, sctx->i_ctx))
                  ^
  233.           goto err;
  234.       if (!EVP_MD_CTX_copy_ex(dctx->o_ctx, sctx->o_ctx))

crypto/mem.c:225:1: parameter `str` of CRYPTO_free
    223.   }
    224.   
    225. > void CRYPTO_free(void *str, const char *file, int line)
    226.   {
    227.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:241:5: invalid access occurs here
    239.       }
    240.   #else
    241.       free(str);
               ^
    242.   #endif
    243.   }
