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:
parent
52620e6493
commit
99d8ce3732
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue