aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--win32/ScintillaWin.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index e3dc8b474..9edd56ad3 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1414,10 +1414,10 @@ void ScintillaWin::Paste() {
// Convert from Unicode to current Scintilla code page
UINT cpDest = CodePageFromCharSet(
vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
- len = ::WideCharToMultiByte(cpDest, 0, uptr, -1,
+ len = ::WideCharToMultiByte(cpDest, 0, uptr, memUSelection.Size() / 2,
NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
putf = new char[len + 1];
- ::WideCharToMultiByte(cpDest, 0, uptr, -1,
+ ::WideCharToMultiByte(cpDest, 0, uptr, memUSelection.Size() / 2,
putf, len + 1, NULL, NULL);
}
@@ -1942,10 +1942,11 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
// Convert to Unicode using the current Scintilla code page
UINT cpSrc = CodePageFromCharSet(
selectedText.characterSet, selectedText.codePage);
- uniText.Allocate(2 * selectedText.len);
+ int uLen = ::MultiByteToWideChar(cpSrc, 0, selectedText.s, selectedText.len, 0, 0);
+ uniText.Allocate(2 * uLen);
if (uniText) {
::MultiByteToWideChar(cpSrc, 0, selectedText.s, selectedText.len,
- static_cast<wchar_t *>(uniText.ptr), selectedText.len);
+ static_cast<wchar_t *>(uniText.ptr), uLen);
}
}