Fix crash during Search result

Fix #11883, close #11889
This commit is contained in:
Don Ho 2022-07-08 17:48:46 +02:00
parent c7c5db7c51
commit e6fe568bbf
2 changed files with 11 additions and 3 deletions

View File

@ -963,6 +963,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{ {
BufferID idd = _mainDocTab.getBufferByIndex(id); BufferID idd = _mainDocTab.getBufferByIndex(id);
Buffer * buf = MainFileManager.getBufferByID(idd); Buffer * buf = MainFileManager.getBufferByID(idd);
if (buf == nullptr)
return FALSE;
tipTmp = buf->getFullPathName(); tipTmp = buf->getFullPathName();
if (tipTmp.length() >= tipMaxLen) if (tipTmp.length() >= tipMaxLen)
@ -975,6 +978,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{ {
BufferID idd = _subDocTab.getBufferByIndex(id); BufferID idd = _subDocTab.getBufferByIndex(id);
Buffer * buf = MainFileManager.getBufferByID(idd); Buffer * buf = MainFileManager.getBufferByID(idd);
if (buf == nullptr)
return FALSE;
tipTmp = buf->getFullPathName(); tipTmp = buf->getFullPathName();
if (tipTmp.length() >= tipMaxLen) if (tipTmp.length() >= tipMaxLen)

View File

@ -77,8 +77,10 @@ static void ColouriseSearchResultLine(SearchResultMarkings* pMarkings, char *lin
styler.ColourTo(startLine + currentPos - 1, SCE_SEARCHRESULT_LINE_NUMBER); styler.ColourTo(startLine + currentPos - 1, SCE_SEARCHRESULT_LINE_NUMBER);
int currentStat = SCE_SEARCHRESULT_DEFAULT; int currentState = SCE_SEARCHRESULT_DEFAULT;
if (linenum >= pMarkings->_length)
return;
SearchResultMarkingLine miLine = pMarkings->_markings[linenum]; SearchResultMarkingLine miLine = pMarkings->_markings[linenum];
for (std::pair<intptr_t, intptr_t> mi : miLine._segmentPostions) for (std::pair<intptr_t, intptr_t> mi : miLine._segmentPostions)
@ -92,11 +94,11 @@ static void ColouriseSearchResultLine(SearchResultMarkings* pMarkings, char *lin
if (match_end <= endPos) if (match_end <= endPos)
styler.ColourTo(match_end, SCE_SEARCHRESULT_WORD2SEARCH); styler.ColourTo(match_end, SCE_SEARCHRESULT_WORD2SEARCH);
else else
currentStat = SCE_SEARCHRESULT_WORD2SEARCH; currentState = SCE_SEARCHRESULT_WORD2SEARCH;
} }
} }
styler.ColourTo(endPos, currentStat); styler.ColourTo(endPos, currentState);
} }
else // every character - search header else // every character - search header
{ {