[EU-FOSSA] Fix crash issue by command "On Selection->Open File"
Fix crash issue by command "On Selection->Open File" while the number of selected characters is exeed 2048.
This commit is contained in:
parent
f7d92eb992
commit
63d3a42c64
@ -2252,11 +2252,17 @@ generic_string ScintillaEditView::getLine(size_t lineNumber)
|
|||||||
|
|
||||||
void ScintillaEditView::getLine(size_t lineNumber, TCHAR * line, int lineBufferLen)
|
void ScintillaEditView::getLine(size_t lineNumber, TCHAR * line, int lineBufferLen)
|
||||||
{
|
{
|
||||||
|
// make sure the buffer length is enough to get the whole line
|
||||||
|
auto lineLen = execute(SCI_LINELENGTH, lineNumber);
|
||||||
|
if (lineLen >= lineBufferLen)
|
||||||
|
return;
|
||||||
|
|
||||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||||
char *lineA = new char[lineBufferLen];
|
char *lineA = new char[lineBufferLen];
|
||||||
// From Scintilla documentation for SCI_GETLINE: "The buffer is not terminated by a 0 character."
|
// From Scintilla documentation for SCI_GETLINE: "The buffer is not terminated by a 0 character."
|
||||||
memset(lineA, 0x0, sizeof(char) * lineBufferLen);
|
memset(lineA, 0x0, sizeof(char) * lineBufferLen);
|
||||||
|
|
||||||
execute(SCI_GETLINE, lineNumber, reinterpret_cast<LPARAM>(lineA));
|
execute(SCI_GETLINE, lineNumber, reinterpret_cast<LPARAM>(lineA));
|
||||||
const TCHAR *lineW = wmc->char2wchar(lineA, cp);
|
const TCHAR *lineW = wmc->char2wchar(lineA, cp);
|
||||||
lstrcpyn(line, lineW, lineBufferLen);
|
lstrcpyn(line, lineW, lineBufferLen);
|
||||||
|
Loading…
Reference in New Issue
Block a user