crypto/evp/digest.c:283: error: USE_AFTER_FREE
  call to `EVP_MD_CTX_copy_ex()` eventually accesses memory that was invalidated by call to `free()` on line 282 indirectly during the call to `EVP_MD_CTX_reset()`.
Showing all 16 steps of the trace


crypto/evp/digest.c:280:1: invalidation part of the trace starts here
278.   }
279.   
280. > int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
281.   {
282.       EVP_MD_CTX_reset(out);

crypto/evp/digest.c:280:1: parameter `out` of EVP_MD_CTX_copy
  278.   }
  279.   
  280. > int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  281.   {
  282.       EVP_MD_CTX_reset(out);

crypto/evp/digest.c:282:5: when calling `EVP_MD_CTX_reset` here
  280.   int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  281.   {
  282.       EVP_MD_CTX_reset(out);
             ^
  283.       return EVP_MD_CTX_copy_ex(out, in);
  284.   }

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.       ENGINE_finish(ctx->engine);

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

crypto/evp/pmeth_lib.c:329:5: when calling `EVP_PKEY_free` here
      327.           ctx->pmeth->cleanup(ctx);
      328.       EVP_PKEY_free(ctx->pkey);
      329.       EVP_PKEY_free(ctx->peerkey);
                 ^
      330.   #ifndef OPENSSL_NO_ENGINE
      331.       ENGINE_finish(ctx->engine);

crypto/evp/p_lib.c:412:1: parameter `x` of EVP_PKEY_free
        410.   }
        411.   
        412. > void EVP_PKEY_free(EVP_PKEY *x)
        413.   {
        414.       int i;

crypto/evp/p_lib.c:426:5: when calling `CRYPTO_free` here
        424.       EVP_PKEY_free_it(x);
        425.       sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
        426.       OPENSSL_free(x);
                   ^
        427.   }
        428.   

crypto/mem.c:210:1: parameter `str` of CRYPTO_free
          208.   }
          209.   
          210. > void CRYPTO_free(void *str, const char *file, int line)
          211.   {
          212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:226:5: was invalidated by call to `free()`
          224.       }
          225.   #else
          226.       free(str);
                     ^
          227.   #endif
          228.   }

crypto/evp/digest.c:280:1: use-after-lifetime part of the trace starts here
278.   }
279.   
280. > int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
281.   {
282.       EVP_MD_CTX_reset(out);

crypto/evp/digest.c:280:1: parameter `out` of EVP_MD_CTX_copy
  278.   }
  279.   
  280. > int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
  281.   {
  282.       EVP_MD_CTX_reset(out);

crypto/evp/digest.c:283:12: when calling `EVP_MD_CTX_copy_ex` here
  281.   {
  282.       EVP_MD_CTX_reset(out);
  283.       return EVP_MD_CTX_copy_ex(out, in);
                    ^
  284.   }
  285.   

crypto/mem.c:210:1: parameter `str` of CRYPTO_free
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:226:5: invalid access occurs here
    224.       }
    225.   #else
    226.       free(str);
               ^
    227.   #endif
    228.   }

void CRYPTO_free(void *str, const char *file, int line)
{
    if (free_impl != NULL && free_impl != &CRYPTO_free) {
        free_impl(str, file, line);
        return;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0, file, line);
        free(str);
        CRYPTO_mem_debug_free(str, 1, file, line);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)\n{\n    EVP_MD_CTX_reset(out);\n    return EVP_MD_CTX_copy_ex(out, in);\n}', 'int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)\n{\n    if (ctx == NULL)\n        return 1;\n    if (ctx->digest && ctx->digest->cleanup\n        && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_CLEANED))\n        ctx->digest->cleanup(ctx);\n    if (ctx->digest && ctx->digest->ctx_size && ctx->md_data\n        && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) {\n        OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);\n    }\n    EVP_PKEY_CTX_free(ctx->pctx);\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(ctx->engine);\n#endif\n    memset(ctx, 0, sizeof(*ctx));\n    return 1;\n}', 'void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    if (ctx->pmeth && ctx->pmeth->cleanup)\n        ctx->pmeth->cleanup(ctx);\n    EVP_PKEY_free(ctx->pkey);\n    EVP_PKEY_free(ctx->peerkey);\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(ctx->engine);\n#endif\n    OPENSSL_free(ctx);\n}', 'void EVP_PKEY_free(EVP_PKEY *x)\n{\n    int i;\n    if (x == NULL)\n        return;\n    i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);\n    REF_PRINT_COUNT("EVP_PKEY", x);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    EVP_PKEY_free_it(x);\n    sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);\n    OPENSSL_free(x);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']