Fixed hang on garbage code (#6824)
This commit is contained in:
parent
749bb34deb
commit
c987a99ac8
|
@ -4500,7 +4500,7 @@ Token *Tokenizer::simplifyAddBracesPair(Token *tok, bool commandWithCondition)
|
|||
tokAfterCondition=tokCondition->link();
|
||||
else
|
||||
tokAfterCondition=nullptr;
|
||||
if (!tokAfterCondition) {
|
||||
if (!tokAfterCondition || tokAfterCondition->strAt(1) == "]") {
|
||||
// Bad condition
|
||||
syntaxError(tok);
|
||||
return nullptr;
|
||||
|
|
|
@ -142,6 +142,7 @@ private:
|
|||
TEST_CASE(garbageCode100);
|
||||
TEST_CASE(garbageCode101); // #6835
|
||||
TEST_CASE(garbageCode102); // #6846
|
||||
TEST_CASE(garbageCode103); // #6824
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -804,6 +805,10 @@ private:
|
|||
checkCode("struct Object { ( ) ; Object & operator= ( Object ) { ( ) { } if ( this != & b ) } }");
|
||||
}
|
||||
|
||||
void garbageCode103() { // #6824
|
||||
ASSERT_THROW(checkCode("a f(r) int * r; { { int s[2]; [f(s); if () ] } }"), InternalError);
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue