From 51ee5feb78d470cb8aa9d3a3cf7aafdca3add12f Mon Sep 17 00:00:00 2001 From: mq1n Date: Mon, 22 Sep 2025 11:25:58 +0300 Subject: [PATCH] fixed some crashes --- src/EffectLib/EffectElementBaseInstance.cpp | 8 ++++++++ src/EterBase/lzo.cpp | 16 ++++------------ src/EterLib/GrpObjectInstance.cpp | 14 ++++++++++++-- src/EterLib/IME.cpp | 3 ++- src/UserInterface/PythonSkill.cpp | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/EffectLib/EffectElementBaseInstance.cpp b/src/EffectLib/EffectElementBaseInstance.cpp index 80f64aa..2e42266 100644 --- a/src/EffectLib/EffectElementBaseInstance.cpp +++ b/src/EffectLib/EffectElementBaseInstance.cpp @@ -90,6 +90,14 @@ void CEffectElementBaseInstance::Destroy() } CEffectElementBaseInstance::CEffectElementBaseInstance() + : mc_pmatLocal(nullptr) + , m_isActive(false) + , m_fLocalTime(0.0f) + , m_dwStartTime(0) + , m_fElapsedTime(0.0f) + , m_fRemainingTime(0.0f) + , m_bStart(false) + , m_pBase(nullptr) { } CEffectElementBaseInstance::~CEffectElementBaseInstance() diff --git a/src/EterBase/lzo.cpp b/src/EterBase/lzo.cpp index 2cbb903..2b7454a 100644 --- a/src/EterBase/lzo.cpp +++ b/src/EterBase/lzo.cpp @@ -216,22 +216,14 @@ public: public: DecryptBuffer(unsigned size) { - static unsigned count = 0; - static unsigned sum = 0; - static unsigned maxSize = 0; - - sum += size; - count++; - - maxSize = std::max(size, maxSize); if (size >= LOCAL_BUF_SIZE) { m_buf = new char[size]; - dbg_printf("DecryptBuffer - AllocHeap %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count); + dbg_printf("DecryptBuffer - AllocHeap %d\n", size); } else { - dbg_printf("DecryptBuffer - AllocStack %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count); + dbg_printf("DecryptBuffer - AllocStack %d\n", size); m_buf = m_local_buf; } } @@ -239,12 +231,12 @@ public: { if (m_local_buf != m_buf) { - dbg_printf("DecruptBuffer - FreeHeap\n"); + dbg_printf("DecryptBuffer - FreeHeap\n"); delete [] m_buf; } else { - dbg_printf("DecruptBuffer - FreeStack\n"); + dbg_printf("DecryptBuffer - FreeStack\n"); } } void* GetBufferPtr() diff --git a/src/EterLib/GrpObjectInstance.cpp b/src/EterLib/GrpObjectInstance.cpp index 65af030..6e9ba11 100644 --- a/src/EterLib/GrpObjectInstance.cpp +++ b/src/EterLib/GrpObjectInstance.cpp @@ -20,7 +20,7 @@ void CGraphicObjectInstance::Clear() m_isVisible = TRUE; m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f; - m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 0.0f; + m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 1.0f; //m_fRotation = 0.0f; m_fYaw = m_fPitch = m_fRoll = 0.0f; D3DXMatrixIdentity(&m_worldMatrix); @@ -278,12 +278,22 @@ void CGraphicObjectInstance::Initialize() m_BlockCamera = false; m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f; - m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 0.0f; + m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 1.0f; m_fYaw = m_fPitch = m_fRoll = 0.0f; D3DXMatrixIdentity(&m_worldMatrix); D3DXMatrixIdentity(&m_mRotation); + m_v3TBBoxMin = D3DXVECTOR3(0.0f, 0.0f, 0.0f); + m_v3TBBoxMax = D3DXVECTOR3(0.0f, 0.0f, 0.0f); + m_v3BBoxMin = D3DXVECTOR3(0.0f, 0.0f, 0.0f); + m_v3BBoxMax = D3DXVECTOR3(0.0f, 0.0f, 0.0f); + + for (int i = 0; i < 8; ++i) + m_v4TBBox[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f); + + memset(m_abyPortalID, 0, sizeof(m_abyPortalID)); + ClearCollision(); OnInitialize(); } diff --git a/src/EterLib/IME.cpp b/src/EterLib/IME.cpp index 781564b..57e0f8c 100644 --- a/src/EterLib/IME.cpp +++ b/src/EterLib/IME.cpp @@ -830,7 +830,8 @@ void CIME::DelCurPos() if (ms_curpos < ms_lastpos) { int eraseCount = FindColorTagEndPosition(m_wText + ms_curpos, ms_lastpos - ms_curpos) + 1; - wcscpy(m_wText + ms_curpos, m_wText + ms_curpos + eraseCount); + size_t remainingChars = ms_lastpos - ms_curpos - eraseCount + 1; // +1 for null terminator + wmemmove(m_wText + ms_curpos, m_wText + ms_curpos + eraseCount, remainingChars); // wcscpy > wmemmove to handle overlapping memory ms_lastpos -= eraseCount; ms_curpos = std::min(ms_lastpos, ms_curpos); } diff --git a/src/UserInterface/PythonSkill.cpp b/src/UserInterface/PythonSkill.cpp index 3e4ad98..b5d2eb2 100644 --- a/src/UserInterface/PythonSkill.cpp +++ b/src/UserInterface/PythonSkill.cpp @@ -71,7 +71,7 @@ void string_replace_word(const char* base, int base_len, const char* src, int sr int cur = 0; while (cur < base_len) { - if (memcmp(base + cur, src, src_len) == 0) + if (cur + src_len <= base_len && memcmp(base + cur, src, src_len) == 0) { result.append(base + prev, cur - prev); result.append(dst, dst_len);