Fix security issue CVE-2022-31901
Ref: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-31901 & https://github.com/CDACesec/CVE-2022-31901 Fix #13520
This commit is contained in:
parent
dca3f682fd
commit
113003a79f
|
@ -3430,9 +3430,27 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
|
||||||
pView->execute(SCI_SETINDICATORVALUE, indicFore);
|
pView->execute(SCI_SETINDICATORVALUE, indicFore);
|
||||||
|
|
||||||
UINT cp = static_cast<UINT>(pView->execute(SCI_GETCODEPAGE));
|
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);
|
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;
|
int wideTextLen = MultiByteToWideChar(cp, 0, encodedText, static_cast<int>(endPos - startPos + 1), (LPWSTR) wideText, static_cast<int>(endPos - startPos + 1)) - 1;
|
||||||
delete[] encodedText;
|
delete[] encodedText;
|
||||||
if (wideTextLen > 0)
|
if (wideTextLen > 0)
|
||||||
|
|
Loading…
Reference in New Issue