From bf835cbeb71b9030a1603870ea12015ae6b4e3de Mon Sep 17 00:00:00 2001 From: jacob Date: Sun, 29 Mar 2026 15:58:39 -0500 Subject: [PATCH] allocate 2 bytes for 16bit clipboard null terminator --- src/platform/platform_win32/platform_win32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/platform_win32/platform_win32.c b/src/platform/platform_win32/platform_win32.c index 7338e706..3a1e4689 100644 --- a/src/platform/platform_win32/platform_win32.c +++ b/src/platform/platform_win32/platform_win32.c @@ -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)