[BUG_FIXED] Fix word-completion crash bug while the word to complete exceeds 256 characters.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@108 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-01-17 22:58:09 +00:00
parent 5b79b33eb1
commit 525960820e

View File

@ -4602,7 +4602,12 @@ void Notepad_plus::autoCompFromCurrentFile(bool autoInsert)
if (curPos == startPos)
return;
char beginChars[256];
const size_t bufSize = 256;
size_t len = (curPos > startPos)?(curPos - startPos):(startPos - curPos);
if (len >= bufSize)
return;
char beginChars[bufSize];
_pEditView->getText(beginChars, startPos, curPos);
@ -4628,14 +4633,18 @@ void Notepad_plus::autoCompFromCurrentFile(bool autoInsert)
{
int wordStart = int(_pEditView->execute(SCI_GETTARGETSTART));
int wordEnd = int(_pEditView->execute(SCI_GETTARGETEND));
//int foundTextLen = wordEnd - wordStart;
char w[256];
size_t foundTextLen = wordEnd - wordStart;
if (foundTextLen < bufSize)
{
char w[bufSize];
_pEditView->getText(w, wordStart, wordEnd);
if (strcmp(w, beginChars))
if (!isInList(w, wordArray))
wordArray.push_back(w);
}
_pEditView->execute(SCI_SETTARGETSTART, wordEnd/*posFind + foundTextLen*/);
_pEditView->execute(SCI_SETTARGETEND, docLength);
posFind = int(_pEditView->execute(SCI_SEARCHINTARGET, expr.length(), (LPARAM)expr.c_str()));