mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 08:24:16 +09:00
[winpr,clipboard] follow up to #10901
CF_UNICODETEXT is UCS-2 encoded, so determine string length with _wscnlen, the other string types are in local encoding which requires strnlen
This commit is contained in:
@@ -492,7 +492,7 @@ BOOL ClipboardSetData(wClipboard* clipboard, UINT32 formatId, const void* data,
|
||||
|
||||
free(clipboard->data);
|
||||
|
||||
clipboard->data = calloc(size + 1, sizeof(char));
|
||||
clipboard->data = calloc(size + sizeof(WCHAR), sizeof(char));
|
||||
|
||||
if (!clipboard->data)
|
||||
return FALSE;
|
||||
@@ -506,9 +506,11 @@ BOOL ClipboardSetData(wClipboard* clipboard, UINT32 formatId, const void* data,
|
||||
{
|
||||
case CF_TEXT:
|
||||
case CF_OEMTEXT:
|
||||
case CF_UNICODETEXT:
|
||||
clipboard->size = strnlen(clipboard->data, size) + 1;
|
||||
break;
|
||||
case CF_UNICODETEXT:
|
||||
clipboard->size = (_wcsnlen(clipboard->data, size / sizeof(WCHAR)) + 1) * sizeof(WCHAR);
|
||||
break;
|
||||
default:
|
||||
clipboard->size = size;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user