From 84ef6918d0ef7f96c78fe149bf65d782ef98aba7 Mon Sep 17 00:00:00 2001 From: craftwar Date: Wed, 11 Jul 2018 09:42:07 +0800 Subject: [PATCH] Fix link len caculation and copy link --- Lite/BBSHyperLink.cpp | 2 +- Lite/Clipboard.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lite/BBSHyperLink.cpp b/Lite/BBSHyperLink.cpp index 133d8d3..c59e43a 100644 --- a/Lite/BBSHyperLink.cpp +++ b/Lite/BBSHyperLink.cpp @@ -147,7 +147,7 @@ const char* CBBSHyperLink::FindHyperLink(const char *src, int &len) const break; } } - len = int(pend) - int(plink); + len = int(pend - plink); return plink; } } diff --git a/Lite/Clipboard.cpp b/Lite/Clipboard.cpp index 4bad156..f40b273 100644 --- a/Lite/Clipboard.cpp +++ b/Lite/Clipboard.cpp @@ -74,7 +74,8 @@ BOOL CClipboard::SetText(HWND owner, LPCTSTR str, int len) { LPSTR buf = (LPSTR)GlobalLock(hmem); PLCID lcid = (PLCID)GlobalLock(hlocmem); - memcpy(buf, str, len + 1); + memcpy(buf, str, len); + buf[len] = '\0'; // FIXME: Big5 should not be hard-coded since we have GB2312 version. *lcid = MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL), SORT_CHINESE_BIG5); GlobalUnlock(hmem);