debugger: Fix clipboard related crash

When copying an address from Cemu's debugger and pasting it into Cemu (anywhere) it would crash because the memory was released prematurely
This commit is contained in:
Exzap 2025-08-17 17:58:22 +02:00
parent d7c510ed31
commit aeb3154257

View file

@ -693,7 +693,8 @@ void DisasmCtrl::OnMouseDClick(const wxPoint& position, uint32 line)
}
}
void DisasmCtrl::CopyToClipboard(std::string text) {
void DisasmCtrl::CopyToClipboard(std::string text)
{
#if BOOST_OS_WINDOWS
if (OpenClipboard(nullptr))
{
@ -703,9 +704,7 @@ void DisasmCtrl::CopyToClipboard(std::string text) {
{
memcpy(GlobalLock(hGlobal), text.c_str(), text.size() + 1);
GlobalUnlock(hGlobal);
SetClipboardData(CF_TEXT, hGlobal);
GlobalFree(hGlobal);
}
CloseClipboard();
}