mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-03-31 01:02:16 +08:00
Add memory leak prevention in DOpus message handler
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user