Add memory leak prevention in DOpus message handler

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-29 13:54:43 +00:00
parent 4c456fc14c
commit 5ebc3ec3db

View File

@@ -138,6 +138,13 @@ LRESULT CALLBACK DOpus::msgWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
auto cds = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
auto buf = static_cast<PCHAR>(cds->lpData);
// Clean up any previous buffer before allocating a new one
if (pXmlBuffer != nullptr)
{
delete[] pXmlBuffer;
pXmlBuffer = nullptr;
}
pXmlBuffer = new CHAR[cds->cbData + 1]{'\0'};
memcpy(pXmlBuffer, buf, cds->cbData);