#6907 segmentation fault (invalid code) in Tokenizer::simplifyTokenList1
This commit is contained in:
parent
0b96b9d984
commit
acf050793e
|
@ -3513,16 +3513,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
// Put ^{} statements in asm()
|
||||
simplifyAsm2();
|
||||
|
||||
// When the assembly code has been cleaned up, no @ is allowed
|
||||
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (tok->str() == "(")
|
||||
tok = tok->link();
|
||||
else if (tok->str()[0] == '@') {
|
||||
list.deallocateTokens();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// convert platform dependent types to standard types
|
||||
// 32 bits: size_t -> unsigned long
|
||||
// 64 bits: size_t -> unsigned long long
|
||||
|
@ -9476,6 +9466,17 @@ void Tokenizer::simplifyAsm2()
|
|||
}
|
||||
}
|
||||
}
|
||||
// When the assembly code has been cleaned up, no @ is allowed
|
||||
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (tok->str() == "(") {
|
||||
tok = tok->link();
|
||||
if (!tok)
|
||||
syntaxError(nullptr);
|
||||
} else if (tok->str()[0] == '@') {
|
||||
list.deallocateTokens();
|
||||
syntaxError(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simplify bitfields
|
||||
|
|
|
@ -150,6 +150,7 @@ private:
|
|||
TEST_CASE(garbageCode108);
|
||||
TEST_CASE(garbageCode109);
|
||||
TEST_CASE(garbageCode110);
|
||||
TEST_CASE(garbageCode111);
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -844,6 +845,10 @@ private:
|
|||
checkCode("( *const<> ( size_t ) ; foo ) { } * ( *const ( size_t ) ( ) ;> foo )< { }");
|
||||
}
|
||||
|
||||
void garbageCode111() { // #6907
|
||||
ASSERT_THROW(checkCode("enum { FOO = 1( ,) } {{ FOO }} ;"), InternalError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void garbageValueFlow() {
|
||||
|
|
|
@ -682,7 +682,7 @@ private:
|
|||
"-(Foo *)foo: (Bar *)bar\n"
|
||||
"{ }\n"
|
||||
"@end\n";
|
||||
ASSERT_EQUALS("", tokenizeAndStringify(code));
|
||||
ASSERT_THROW(tokenizeAndStringify(code), InternalError);
|
||||
}
|
||||
|
||||
// Ticket #2361: 0X10 => 16
|
||||
|
|
Loading…
Reference in New Issue