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


crypto/hmac/hmac.c:131:1: invalidation part of the trace starts here
129.   
130.   #if OPENSSL_API_COMPAT < 0x10100000L
131. > int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
132.   {
133.       if (key && md)

crypto/hmac/hmac.c:131:1: parameter `ctx` of HMAC_Init
  129.   
  130.   #if OPENSSL_API_COMPAT < 0x10100000L
  131. > int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
  132.   {
  133.       if (key && md)

crypto/hmac/hmac.c:134:9: when calling `HMAC_CTX_reset` here
  132.   {
  133.       if (key && md)
  134.           HMAC_CTX_reset(ctx);
                 ^
  135.       return HMAC_Init_ex(ctx, key, len, md, NULL);
  136.   }

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

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

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

crypto/hmac/hmac.c:187:5: when calling `EVP_MD_CTX_reset` here
      185.       EVP_MD_CTX_reset(ctx->i_ctx);
      186.       EVP_MD_CTX_reset(ctx->o_ctx);
      187.       EVP_MD_CTX_reset(ctx->md_ctx);
                 ^
      188.       ctx->md = NULL;
      189.       ctx->key_length = 0;

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/hmac/hmac.c:131:1: use-after-lifetime part of the trace starts here
129.   
130.   #if OPENSSL_API_COMPAT < 0x10100000L
131. > int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
132.   {
133.       if (key && md)

crypto/hmac/hmac.c:131:1: parameter `ctx` of HMAC_Init
  129.   
  130.   #if OPENSSL_API_COMPAT < 0x10100000L
  131. > int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
  132.   {
  133.       if (key && md)

crypto/hmac/hmac.c:135:12: when calling `HMAC_Init_ex` here
  133.       if (key && md)
  134.           HMAC_CTX_reset(ctx);
  135.       return HMAC_Init_ex(ctx, key, len, md, NULL);
                    ^
  136.   }
  137.   #endif

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