I found a memory leak in NCrypto::NRar3::CDecoder.
The version of 7zip for this test:
for Windows : 16.04, download from https://sourceforge.net/projects/sevenzip/files/7-Zip/16.04/
for Linux : 16.02, download from https://sourceforge.net/projects/p7zip/files/p7zip/16.02/
we can see the relationship of
class NCrypto:: NRar3::CDecoder and struct NCrypto::CAesCbcDecoder and class NCrypto::CAesCbcCoder
is
class NCrypto:: NRar3::CDecoder inherited from struct NCrypto::CAesCbcDecoder inherited from class NCrypto::CAesCbcCoder,
and class NCrypto::CAesCbcCoder inherited from CMyUnknownImp,
and implements COM methods AddRef(), Release(), QueryInterface and so on.
as Effiective C++ say:
Item 7: Declare destructors virtual in polymorphic base classes.
Then come up to this question, we should explicit write virtual ~CAesCbcCoder(), and virtual ~CAesCbcDecoder to make sure instance of class NCrypto:: NRar3::CDecoder properly delete.
To see this memory leak, you can call Extract the attachment that I supply with password 123.
also, I use _CrtDumpMemoryLeaks to see this memory leak,
reference https://social.msdn.microsoft.com/Forums/vstudio/en-US/40f13e06-4c08-4234-8acf-9e51a5c05aa9/turning-off-crtdumpmemoryleaks?forum=vcgeneral
Thanks for report!
I'll fix it.
Probably it's enough to write
virtualonly for one base class:So probably we can use also:
But the code is larger, if we use virtual destructors for all CMyUnknownImp classes.
I'll try to find good solution.