CryptoPP::StreamTransformationFilter memory leak possible

I try to integrate the latest version of CryptoPP into UE4 and follow the example in the Wiki, but an error occurred on line 226

222 CFB_Mode< AES >::Encryption e;
223 e.SetKeyWithIV(key_byte, sizeof(key_byte), iv_byte);
224
225 StringSource ss(plain, true,
226	    new StreamTransformationFilter(e,
227  		new StringSink(cipher), BlockPaddingSchemeDef::DEFAULT_PADDING
228 	)
229 );

Error message:

line 589 of CryptoPP::filters.cpp



    588 const bool authenticatedFilter = dynamic_cast<AuthenticatedSymmetricCipher *>(&c) != NULLPTR;
    589 if (authenticatedFilter)
    590 	throw InvalidArgument("StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher");
Exception thrown at 0x00007FFF04DA5D20 (vcruntime140.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x000000BFC2AE405C. occurred

stack trace:

attachment	Variable is optimized away and not available.

I also used another way of writing



In the above link, this method did not cause an error in the encryption
230 StreamTransformationFilter stf(e, new StringSink(cipher));
231	stf.Put(reinterpret_cast<const unsigned char*>(plain.c_str()), plain.length() + 1);
232	stf.MessageEnd();

But it still gives the same error

I don't know how to solve this problem

In order to ensure the unity of the problem, I list some of my settings

CryptoPP 8.2

using static lib

Hi there @PunkaDivic,

Hope you’re well!

This topic has been moved from Community to Programming & Scripting: C++.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing!