allocate 2 bytes for 16bit clipboard null terminator

This commit is contained in:
jacob 2026-03-29 15:58:39 -05:00
parent 2f39fb2807
commit bf835cbeb7

View File

@ -522,13 +522,13 @@ void PLT_MessageBox(PLT_MessageBoxKind kind, String message)
void PLT_SetClipboardText(String str)
{
TempArena scratch = BeginScratchNoConflict();
if (OpenClipboard(0))
{
TempArena scratch = BeginScratchNoConflict();
String16 str16 = String16FromString(scratch.arena, str);
u64 str16_size_bytes = str16.len * 2;
EmptyClipboard();
HANDLE handle = GlobalAlloc(GMEM_MOVEABLE, str16_size_bytes + 1);
HANDLE handle = GlobalAlloc(GMEM_MOVEABLE, str16_size_bytes + 2);
if (handle)
{
u16 *dest_wstr = (u16 *)GlobalLock(handle);
@ -538,8 +538,8 @@ void PLT_SetClipboardText(String str)
SetClipboardData(CF_UNICODETEXT, handle);
}
CloseClipboard();
EndScratch(scratch);
}
EndScratch(scratch);
}
String PLT_GetClipboardText(Arena *arena)