Merge pull request #592 from simartin/ticket_6666
Ticket #6666: Don't crash upon garbage code in CheckLeakAutoVar::checkScope
This commit is contained in:
commit
f8d8856d09
|
@ -150,8 +150,11 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
// Parse all tokens
|
||||
const Token * const endToken = startToken->link();
|
||||
for (const Token *tok = startToken; tok && tok != endToken; tok = tok->next()) {
|
||||
if (!tok->scope()->isExecutable())
|
||||
if (!tok->scope()->isExecutable()) {
|
||||
tok = tok->scope()->classEnd;
|
||||
if (!tok) // Ticket #6666 (crash upon invalid code)
|
||||
break;
|
||||
}
|
||||
|
||||
// Deallocation and then dereferencing pointer..
|
||||
if (tok->varId() > 0) {
|
||||
|
|
|
@ -76,6 +76,7 @@ private:
|
|||
TEST_CASE(garbageCode35); // #2599, #2604
|
||||
TEST_CASE(garbageCode36); // #6334
|
||||
TEST_CASE(garbageCode37); // #5166
|
||||
TEST_CASE(garbageCode38); // #6666
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -445,6 +446,10 @@ private:
|
|||
checkCode("void * f { } void b ( ) { * f }");
|
||||
}
|
||||
|
||||
void garbageCode38() { // Ticket #6666
|
||||
checkCode("{ f2 { } } void f3 () { delete[] } { }");
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue