Various memory-related bug fixes

Also new lzokay API to reduce erroneous usage.
This commit is contained in:
Jack Andersen 2019-06-13 20:27:33 -10:00
parent 4c873591f0
commit 036c56370c
5 changed files with 18 additions and 11 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -219,6 +219,11 @@ CWorldEditor::CWorldEditor(QWidget *parent)
CWorldEditor::~CWorldEditor() 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 mpScriptSidebar; // For some reason WCreateTab filters an event during the viewport's destructor
delete ui; delete ui;
} }