winemac: Fix some bytes-vs-WCHARs length computation bugs in the UTF-16 clipboard support.
This commit is contained in:
parent
0153a962f6
commit
c7f8e71ab6
|
@ -1007,7 +1007,7 @@ static HANDLE import_utf16_to_unicodetext(CFDataRef data)
|
||||||
HANDLE unicode_handle;
|
HANDLE unicode_handle;
|
||||||
|
|
||||||
src = (const WCHAR *)CFDataGetBytePtr(data);
|
src = (const WCHAR *)CFDataGetBytePtr(data);
|
||||||
data_len = CFDataGetLength(data);
|
data_len = CFDataGetLength(data) / sizeof(WCHAR);
|
||||||
for (i = 0; i < data_len; i++)
|
for (i = 0; i < data_len; i++)
|
||||||
{
|
{
|
||||||
if (src[i] == '\n')
|
if (src[i] == '\n')
|
||||||
|
@ -1358,13 +1358,13 @@ static CFDataRef export_unicodetext_to_utf16(HANDLE data)
|
||||||
|
|
||||||
dst_len = GlobalSize(data) / sizeof(WCHAR);
|
dst_len = GlobalSize(data) / sizeof(WCHAR);
|
||||||
if (dst_len) dst_len--; /* Leave off null terminator. */
|
if (dst_len) dst_len--; /* Leave off null terminator. */
|
||||||
ret = CFDataCreateMutable(NULL, dst_len);
|
ret = CFDataCreateMutable(NULL, dst_len * sizeof(WCHAR));
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
LPWSTR dst;
|
LPWSTR dst;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
CFDataSetLength(ret, dst_len);
|
CFDataSetLength(ret, dst_len * sizeof(WCHAR));
|
||||||
dst = (LPWSTR)CFDataGetMutableBytePtr(ret);
|
dst = (LPWSTR)CFDataGetMutableBytePtr(ret);
|
||||||
|
|
||||||
/* Remove carriage returns */
|
/* Remove carriage returns */
|
||||||
|
@ -1375,7 +1375,7 @@ static CFDataRef export_unicodetext_to_utf16(HANDLE data)
|
||||||
continue;
|
continue;
|
||||||
dst[j++] = src[i];
|
dst[j++] = src[i];
|
||||||
}
|
}
|
||||||
CFDataSetLength(ret, j);
|
CFDataSetLength(ret, j * sizeof(WCHAR));
|
||||||
}
|
}
|
||||||
GlobalUnlock(data);
|
GlobalUnlock(data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue