Merge pull request #168 from simartin/ticket_4994
Ticket #4994: Don't crash when checking variable scope for invalid input
This commit is contained in:
commit
4b1254bc8d
|
@ -2256,8 +2256,11 @@ void Scope::getVariableList()
|
|||
|
||||
// skip return and delete
|
||||
else if (Token::Match(tok, "return|delete")) {
|
||||
while (tok->next() && tok->next()->str() != ";")
|
||||
while (tok->next() &&
|
||||
tok->next()->str() != ";" &&
|
||||
tok->next()->str() != "}" /* ticket #4994 */) {
|
||||
tok = tok->next();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
TEST_CASE(varScope16);
|
||||
TEST_CASE(varScope17);
|
||||
TEST_CASE(varScope18);
|
||||
TEST_CASE(varScope19); // Ticket #4994
|
||||
|
||||
TEST_CASE(oldStylePointerCast);
|
||||
TEST_CASE(invalidPointerCast);
|
||||
|
@ -1081,6 +1082,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varScope19() { // Ticket #4994
|
||||
varScope("long f () {\n"
|
||||
" return a >> extern\n"
|
||||
"}\n"
|
||||
"long a = 1 ;\n"
|
||||
"long b = 2 ;");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkOldStylePointerCast(const char code[]) {
|
||||
// Clear the error buffer..
|
||||
errout.str("");
|
||||
|
|
Loading…
Reference in New Issue