mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-31 01:34:58 +02:00
UDL lexer: fix potential infinite loop
Fixed a condition in a loop which is always true (unsigned >= 0) and can potentially turn the loop infinite. And removed a check after the loop which now is also always false. Close #10597
This commit is contained in:
parent
4d57f5071f
commit
49c3e5d553
@ -785,6 +785,8 @@ static inline void StringToVector(char * original, vector<string> & tokenVector,
|
|||||||
static inline void ReColoringCheck(Sci_PositionU & startPos, int & nestedLevel, int & initStyle, int & openIndex,
|
static inline void ReColoringCheck(Sci_PositionU & startPos, int & nestedLevel, int & initStyle, int & openIndex,
|
||||||
int & isCommentLine, bool & isInComment, Accessor & styler, vector<nestedInfo> & lastNestedGroup,
|
int & isCommentLine, bool & isInComment, Accessor & styler, vector<nestedInfo> & lastNestedGroup,
|
||||||
vector<nestedInfo> & nestedVector, /* vector<int> & foldVector, */ int & continueCommentBlock)
|
vector<nestedInfo> & nestedVector, /* vector<int> & foldVector, */ int & continueCommentBlock)
|
||||||
|
{
|
||||||
|
if (startPos > 0)
|
||||||
{
|
{
|
||||||
// re-coloring always starts at line beginning !!
|
// re-coloring always starts at line beginning !!
|
||||||
|
|
||||||
@ -795,11 +797,9 @@ static inline void ReColoringCheck(Sci_PositionU & startPos, int & nestedLevel,
|
|||||||
|| initStyle == SCE_USER_STYLE_FOLDER_IN_CODE2 )
|
|| initStyle == SCE_USER_STYLE_FOLDER_IN_CODE2 )
|
||||||
{
|
{
|
||||||
// we are in middle of multi-part keyword that contains newline characters, go back until current style ends
|
// we are in middle of multi-part keyword that contains newline characters, go back until current style ends
|
||||||
while (startPos >= 0 && styler.StyleAt(--startPos) == initStyle);
|
while (startPos > 0 && styler.StyleAt(--startPos) == initStyle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static_cast<int>(startPos) < 0)
|
|
||||||
startPos = 0;
|
|
||||||
|
|
||||||
if (startPos > 0)
|
if (startPos > 0)
|
||||||
{
|
{
|
||||||
@ -808,8 +808,6 @@ static inline void ReColoringCheck(Sci_PositionU & startPos, int & nestedLevel,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ch = styler.SafeGetCharAt(--startPos);
|
ch = styler.SafeGetCharAt(--startPos);
|
||||||
if (startPos == -1)
|
|
||||||
startPos = 0;
|
|
||||||
}
|
}
|
||||||
while(ch != '\r' && ch != '\n' && startPos > 0);
|
while(ch != '\r' && ch != '\n' && startPos > 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user