Fixed #4941 (segmentation fault (invalid code) in Tokenizer::setVarId)

This commit is contained in:
Daniel Marjamäki 2013-08-28 19:52:41 +02:00
parent 2eca0a93a7
commit 3bd1d53c75
2 changed files with 3 additions and 2 deletions

View File

@ -1806,7 +1806,7 @@ bool Tokenizer::tokenize(std::istream &code,
const Token *last = tok->next()->link();
if (start != tok) {
last = last->next();
while (last && !Token::Match(last, "[;{}]"))
while (last && !Token::Match(last->next(), "[;{}()]"))
last = last->next();
}
if (start && last) {

View File

@ -746,7 +746,8 @@ private:
// #4725 - ^{}
void tokenize28() {
ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }"));
ASSERT_EQUALS("void f ( ) { asm ( \"x(^{});\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }"));
ASSERT_EQUALS("void f ( ) { asm ( \"x(^{})\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }"));
ASSERT_EQUALS("; asm ( \"voidf^{return}intmain\" ) ; ( ) { }", tokenizeAndStringify("; void f ^ { return } int main ( ) { }"));
}
void wrong_syntax1() {