fix #2834 (crash of cppcheck (std::vector<int>::iterator))
This commit is contained in:
parent
5e3263235b
commit
d1b260699a
|
@ -5931,7 +5931,7 @@ void Tokenizer::simplifyVarDecl()
|
|||
}
|
||||
}
|
||||
|
||||
if (!tok2)
|
||||
if (!tok2) // syntax error
|
||||
break;
|
||||
|
||||
if (Token::Match(tok2, ":: %type%"))
|
||||
|
@ -5940,6 +5940,9 @@ void Tokenizer::simplifyVarDecl()
|
|||
tok2 = tok2->tokAt(2);
|
||||
}
|
||||
|
||||
if (!tok2) // syntax error
|
||||
break;
|
||||
|
||||
if (tok2->str() == "*")
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
|
|
|
@ -352,7 +352,8 @@ private:
|
|||
TEST_CASE(removeUnnecessaryQualification2);
|
||||
|
||||
TEST_CASE(simplifyIfNotNull);
|
||||
TEST_CASE(simplifyVarDecl); // ticket # 2682 segmentation fault
|
||||
TEST_CASE(simplifyVarDecl1); // ticket # 2682 segmentation fault
|
||||
TEST_CASE(simplifyVarDecl2); // ticket # 2834 segmentation fault
|
||||
}
|
||||
|
||||
std::string tok(const char code[], bool simplify = true)
|
||||
|
@ -6986,12 +6987,19 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyVarDecl() // ticket # 2682 segmentation fault
|
||||
void simplifyVarDecl1() // ticket # 2682 segmentation fault
|
||||
{
|
||||
const char code[] = "x a[0] =";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyVarDecl2() // ticket # 2834 segmentation fault
|
||||
{
|
||||
const char code[] = "std::vector<int>::iterator";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSimplifyTokens)
|
||||
|
|
Loading…
Reference in New Issue