Fix Valgrind error in arraySize():

if there's code like: 'int [ ] a = { 1 , 5 , }', 'end' is last '}', when 'tok2' arrives to second ',' and cppcheck finds out that next token to 'tok2' is '}', remove this ',' with 'tok2->deleteThis()' but it causes (maybe) a memory corruption to 'end' which will gave problems later because 'tok' will be assigned to it or its next token.
This commit is contained in:
Edoardo Prezioso 2011-12-12 02:23:49 +01:00
parent 52620e6493
commit 99d8ce3732
1 changed files with 4 additions and 2 deletions

View File

@ -2618,8 +2618,10 @@ void Tokenizer::arraySize()
} else if (tok2->str() == ",") {
if (!Token::Match(tok2->next(), "[},]"))
++sz;
else
tok2->deleteThis();
else {
tok2 = tok2->previous();
tok2->deleteNext();
}
}
}