Fixed #2612 (segmentation fault of cppcheck ( <><< ))

This commit is contained in:
Daniel Marjamäki 2011-03-06 09:33:46 +01:00
parent 0debba4409
commit 779dba9160
2 changed files with 8 additions and 1 deletions

View File

@ -2057,7 +2057,7 @@ bool Tokenizer::tokenize(std::istream &code,
{
tok->str(tok->str() + c2);
tok->deleteNext();
if (c1 == '<' && tok->next()->str() == "=")
if (c1 == '<' && Token::simpleMatch(tok->next(), "="))
{
tok->str("<<=");
tok->deleteNext();

View File

@ -49,6 +49,7 @@ private:
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
TEST_CASE(tokenize14); // tokenize "0X10" => 16
TEST_CASE(tokenize15); // tokenize ".123"
TEST_CASE(tokenize16); // #2612 - segfault for "<><<"
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -516,6 +517,12 @@ private:
ASSERT_EQUALS("0.125", tokenizeAndStringify(".125"));
}
// #2612 - segfault for "<><<"
void tokenize16()
{
tokenizeAndStringify("<><<");
}
void wrong_syntax()
{
{