aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
authornyamatongwe <unknown>2003-11-06 11:56:33 +0000
committernyamatongwe <unknown>2003-11-06 11:56:33 +0000
commite751a5dc21c0e46a3a4ff0e91a741429180b6b1f (patch)
treeb96e4269877fd0fa25864ef5da4fb5ef5bf789f7 /win32
parent18f99b99b3209aee3daa295aad70ef3f0a086552 (diff)
downloadscintilla-mirror-e751a5dc21c0e46a3a4ff0e91a741429180b6b1f.tar.gz
SelectionText has been holding a terminating NUL but some client code
was adding an extra NUL. Documented this and avoid adding extra NUL.
Diffstat (limited to 'win32')
-rw-r--r--win32/ScintillaWin.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 097b8a84f..7f52560d5 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1559,11 +1559,10 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
::EmptyClipboard();
HGLOBAL hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
- selectedText.len + 1);
+ selectedText.len);
if (hand) {
char *ptr = static_cast<char *>(::GlobalLock(hand));
memcpy(ptr, selectedText.s, selectedText.len);
- ptr[selectedText.len] = '\0';
::GlobalUnlock(hand);
}
::SetClipboardData(CF_TEXT, hand);
@@ -1571,11 +1570,10 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
if (IsUnicodeMode()) {
int uchars = UCS2Length(selectedText.s, selectedText.len);
HGLOBAL uhand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,
- 2 * (uchars + 1));
+ 2 * (uchars));
if (uhand) {
wchar_t *uptr = static_cast<wchar_t *>(::GlobalLock(uhand));
UCS2FromUTF8(selectedText.s, selectedText.len, uptr, uchars);
- uptr[uchars] = 0;
::GlobalUnlock(uhand);
}
::SetClipboardData(CF_UNICODETEXT, uhand);
@@ -1870,20 +1868,18 @@ STDMETHODIMP ScintillaWin::GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM) {
HGLOBAL hand;
if (pFEIn->cfFormat == CF_UNICODETEXT) {
int uchars = UCS2Length(drag.s, drag.len);
- hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 2 * (uchars + 1));
+ hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 2 * (uchars));
if (hand) {
wchar_t *uptr = static_cast<wchar_t *>(::GlobalLock(hand));
UCS2FromUTF8(drag.s, drag.len, uptr, uchars);
- uptr[uchars] = 0;
}
} else {
- hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, drag.len + 1);
+ hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, drag.len);
if (hand) {
char *ptr = static_cast<char *>(::GlobalLock(hand));
for (int i = 0; i < drag.len; i++) {
ptr[i] = drag.s[i];
}
- ptr[drag.len] = '\0';
}
}
::GlobalUnlock(hand);