Basically, this is what I have:

```
{
    shared_ptr<EVP_PKEY> evpKeyPtr{EVP_PKEY_new(), EVP_PKEY_free};
    //get key from file
}

```

This causes a heap corruption. As well as this:

```
shared_ptr<EVP_PKEY> evpKeyPtr{EVP_PKEY_new(), EVP_PKEY_free};
//same code as above to get key from file
EVP_PKEY_free(evpKeyPtr.get());
//evpKeyPtr does not go out of scope before the corruption occurs

```

But this does not:

```
EVP_PKEY* evpKey = EVP_PKEY_new();
//same code as above to get key from file
EVP_PKEY_free(evpKey);

```

I am at a loss as to why this could be occurring. I know the second code is unadvised, but I did it to test what happens.