Hi everyone, I would like to share a memory leak fix about pack type Hybrid, Hybrid with SDB and panama. I saw it while analyzing Webzen's new pack type.
EterPack.cpp
Search this:
if( !m_pCSHybridCryptPolicy->DecryptMemory(std::string(filename), static_cast<const BYTE*>(*data), index->data_size, *zObj) )
{
return false;
}
Replace with this
if( !m_pCSHybridCryptPolicy->DecryptMemory(std::string(filename), static_cast<const BYTE*>(*data), index->data_size, *zObj) )
{
delete zObj;
return false;
}
Search this:
if( !m_pCSHybridCryptPolicy->GetSupplementaryDataBlock(std::string(filename), pSDBData, iSDBSize) )
{
return false;
}
Replace with this
if( !m_pCSHybridCryptPolicy->GetSupplementaryDataBlock(std::string(filename), pSDBData, iSDBSize) )
{
delete zObj;
return false;
}
Search this:
else if (COMPRESSED_TYPE_PANAMA == index->compressed_type)
{
CLZObject * zObj = new CLZObject;
__Decrypt_Panama(filename, static_cast<const BYTE*>(*data), index->data_size, *zObj);
out_file.BindLZObjectWithBufferedSize(zObj);
*data = zObj->GetBuffer();
}
Replace with this:
else if (COMPRESSED_TYPE_PANAMA == index->compressed_type)
{
CLZObject * zObj = new CLZObject;
if (!__Decrypt_Panama(filename, static_cast<const BYTE*>(*data), index->data_size, *zObj))
{
delete zObj;
return false;
}
out_file.BindLZObjectWithBufferedSize(zObj);
*data = zObj->GetBuffer();
}
Best Regards
Ken