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


crypto/hmac/hmac.c:255:14: invalidation part of the trace starts here
253.       if (md == NULL)
254.           md = m;
255.       if ((c = HMAC_CTX_new()) == NULL)
                    ^
256.           goto err;
257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))

crypto/hmac/hmac.c:255:14: when calling `HMAC_CTX_new` here
  253.       if (md == NULL)
  254.           md = m;
  255.       if ((c = HMAC_CTX_new()) == NULL)
                      ^
  256.           goto err;
  257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))

crypto/hmac/hmac.c:175:33: passed as argument to `CRYPTO_zalloc`
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
                                           ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:175:33: return from call to `CRYPTO_zalloc`
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
                                           ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:175:5: assigned
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
               ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:177:14: when calling `HMAC_CTX_reset` here
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {
                        ^
    178.               HMAC_CTX_free(ctx);
    179.               ctx = NULL;

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

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

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

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

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

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

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

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

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

crypto/hmac/hmac.c:255:14: use-after-lifetime part of the trace starts here
253.       if (md == NULL)
254.           md = m;
255.       if ((c = HMAC_CTX_new()) == NULL)
                    ^
256.           goto err;
257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))

crypto/hmac/hmac.c:255:14: passed as argument to `HMAC_CTX_new`
  253.       if (md == NULL)
  254.           md = m;
  255.       if ((c = HMAC_CTX_new()) == NULL)
                      ^
  256.           goto err;
  257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))

crypto/hmac/hmac.c:175:33: passed as argument to `CRYPTO_zalloc`
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
                                           ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:175:33: return from call to `CRYPTO_zalloc`
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
                                           ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:175:5: assigned
    173.   HMAC_CTX *HMAC_CTX_new(void)
    174.   {
    175.       HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
               ^
    176.       if (ctx)
    177.           if (!HMAC_CTX_reset(ctx)) {

crypto/hmac/hmac.c:255:14: return from call to `HMAC_CTX_new`
  253.       if (md == NULL)
  254.           md = m;
  255.       if ((c = HMAC_CTX_new()) == NULL)
                      ^
  256.           goto err;
  257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))

crypto/hmac/hmac.c:257:10: when calling `HMAC_Init_ex` here
  255.       if ((c = HMAC_CTX_new()) == NULL)
  256.           goto err;
  257.       if (!HMAC_Init_ex(c, key, key_len, evp_md, NULL))
                  ^
  258.           goto err;
  259.       if (!HMAC_Update(c, d, n))

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