diff --git a/src/posix/i_system.cpp b/src/posix/i_system.cpp index f87cf76ae1..0a1b2f69a1 100644 --- a/src/posix/i_system.cpp +++ b/src/posix/i_system.cpp @@ -699,7 +699,12 @@ FString I_GetFromClipboard (bool use_primary_selection) if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF8PlainText)) { - result = reinterpret_cast(CFDataGetBytePtr(data)); + const CFIndex bufferLength = CFDataGetLength(data); + char* const buffer = result.LockNewBuffer(bufferLength); + + memcpy(buffer, CFDataGetBytePtr(data), bufferLength); + + result.UnlockBuffer(); } else if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF16PlainText)) {