Fix some out of index errors

Closes #1851
[PowerEditor/src/Parameters.cpp:2581]: (warning) Array index -1 is out of bounds. Otherwise there is useless condition at line 2568.
[PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp:3079]: (style) Unused variable: newline
[PowerEditor/src/WinControls/Grid/BabyGrid.cpp:166]: (style) Array index 'j' is used before limits check.
[PowerEditor/src/WinControls/Grid/BabyGrid.cpp:171]: (style) Array index 'j' is used before limits check.
[scintilla/lexers/LexUser.cxx:1128]: (error) Array 'maskMapper[15]' accessed at index 15, which is out of bounds.
This commit is contained in:
Julien Nabet 2016-05-12 22:12:58 +02:00 committed by Don Ho
parent d6c2d6cc9f
commit 7b596fa488
4 changed files with 9 additions and 14 deletions

View File

@ -2565,24 +2565,20 @@ bool NppParameters::importUDLFromFile(generic_string sourceFile)
bool NppParameters::exportUDLToFile(int langIndex2export, generic_string fileName2save)
{
if (langIndex2export != -1 && langIndex2export >= _nbUserLang)
if (langIndex2export >= NB_MAX_USER_LANG)
return false;
if (langIndex2export < 0 && langIndex2export >= _nbUserLang)
return false;
TiXmlDocument *pNewXmlUserLangDoc = new TiXmlDocument(fileName2save);
TiXmlNode *newRoot2export = pNewXmlUserLangDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
bool b = false;
if ( langIndex2export >= NB_MAX_USER_LANG )
{
return false;
}
insertUserLang2Tree(newRoot2export, _userLangArray[langIndex2export]);
b = pNewXmlUserLangDoc->SaveFile();
bool result = pNewXmlUserLangDoc->SaveFile();
delete pNewXmlUserLangDoc;
return b;
return result;
}
LangType NppParameters::getLangFromExt(const TCHAR *ext)

View File

@ -3076,7 +3076,6 @@ void ScintillaEditView::changeTextDirection(bool isRTL)
generic_string ScintillaEditView::getEOLString()
{
const int eol_mode = int(execute(SCI_GETEOLMODE));
string newline;
if (eol_mode == SC_EOL_CRLF)
{
return TEXT("\r\n");

View File

@ -163,12 +163,12 @@ int GetNextColWithWidth(int SI, int startcol, int direction)
if(direction == 1){j++;}
if(direction != 1){j--;}
while((BGHS[SI].columnwidths[j] == 0)&&(j<=BGHS[SI].cols)&&(j>0))
while((j>0)&&(j<=BGHS[SI].cols)&&(BGHS[SI].columnwidths[j] == 0))
{
if(direction == 1){j++;}
if(direction != 1){j--;}
}
if((BGHS[SI].columnwidths[j] > 0)&&(j<=BGHS[SI].cols))
if((j<=BGHS[SI].cols)&&(BGHS[SI].columnwidths[j] > 0))
{
ReturnValue = j;
}

View File

@ -1123,7 +1123,7 @@ static void setBackwards(WordList * kwLists[], StyleContext & sc, bool prefixes[
int folding = FOLD_NONE;
int moveForward = 0;
for (int i=0; i<=MAPPER_TOTAL; ++i)
for (int i=0; i<MAPPER_TOTAL; ++i)
{
if (nestedKey & maskMapper[i])
{