Merge pull request #14 from jackoalan/memory-fixes

Various memory-related bug fixes
This commit is contained in:
Aruki 2019-06-14 23:02:22 -07:00 committed by GitHub
commit aad6f5a0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View File

@ -32,10 +32,10 @@
},
{
"name": "lzokay",
"url": "https://github.com/sfuller/lzokay",
"url": "https://github.com/jackoalan/lzokay",
"type": "git",
"head": "cmake",
"ref": "87467048df10e72540a5abcac9dd5c0c4df3a712"
"head": "master",
"ref": "343f9707f6ab2143d3455c93d8b7570a0ffcee97"
},
{
"name": "tinyxml2",

View File

@ -102,11 +102,11 @@ namespace CompressionUtil
else return true;
}
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
{
#if USE_LZOKAY
size_t TotalOut = rTotalOut;
lzokay::EResult Result = lzokay::decompress(pSrc, (size_t) SrcLen, pDst, TotalOut);
size_t TotalOut;
lzokay::EResult Result = lzokay::decompress(pSrc, (size_t) SrcLen, pDst, DstLen, TotalOut);
rTotalOut = TotalOut;
if (Result < lzokay::EResult::Success)
@ -172,7 +172,7 @@ namespace CompressionUtil
// No zlib magic - this is LZO
else
{
bool Success = DecompressLZO(pSrc, Size, pDst, TotalOut);
bool Success = DecompressLZO(pSrc, Size, pDst, (uint32) (pDstEnd - pDst), TotalOut);
if (!Success) return false;
}
@ -220,8 +220,9 @@ namespace CompressionUtil
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
{
#if USE_LZOKAY
rTotalOut = DstLen;
lzokay::EResult Result = lzokay::compress(pSrc, (size_t) SrcLen, pDst, (size_t&) rTotalOut);
size_t TotalOut;
lzokay::EResult Result = lzokay::compress(pSrc, (size_t) SrcLen, pDst, DstLen, TotalOut);
rTotalOut = TotalOut;
if (Result < lzokay::EResult::Success)
{

View File

@ -70,7 +70,7 @@ public:
virtual void Destruct(void* pData) const
{
RevertToDefault(pData);
TTypedProperty::Destruct(pData);
_GetInternalArray(pData).~SScriptArray();
}
virtual bool MatchesDefault(void* pData) const

View File

@ -280,7 +280,8 @@ CDependencyTree* CStringTable::BuildDependencyTree() const
{
if (Game() >= EGame::CorruptionProto)
{
ASSERT(ParamString.StartsWith("0x"));
if (!ParamString.StartsWith("0x"))
continue;
ParamString = ParamString.ChopFront(2);
}

View File

@ -219,6 +219,11 @@ CWorldEditor::CWorldEditor(QWidget *parent)
CWorldEditor::~CWorldEditor()
{
mScene.ClearScene();
mpArea = nullptr;
mpWorld = nullptr;
gpResourceStore->DestroyUnreferencedResources(); // this should destroy the area!
delete mpScriptSidebar; // For some reason WCreateTab filters an event during the viewport's destructor
delete ui;
}