Don Ho 2023-09-15 03:13:22 +02:00
parent dca3f682fd
commit 113003a79f
1 changed files with 20 additions and 2 deletions

View File

@ -3430,9 +3430,27 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
pView->execute(SCI_SETINDICATORVALUE, indicFore);
UINT cp = static_cast<UINT>(pView->execute(SCI_GETCODEPAGE));
char *encodedText = new char[endPos - startPos + 1];
char* encodedText = nullptr;
try {
encodedText = new char[endPos - startPos + 1];
}
catch (const std::bad_alloc&)
{
return;
}
pView->getText(encodedText, startPos, endPos);
TCHAR *wideText = new TCHAR[endPos - startPos + 1];
TCHAR* wideText = nullptr;
try
{
wideText = new TCHAR[endPos - startPos + 1];
}
catch (const std::bad_alloc&)
{
delete[] encodedText;
return;
}
int wideTextLen = MultiByteToWideChar(cp, 0, encodedText, static_cast<int>(endPos - startPos + 1), (LPWSTR) wideText, static_cast<int>(endPos - startPos + 1)) - 1;
delete[] encodedText;
if (wideTextLen > 0)