Fix segmentation fault that happens with invalid code.
This commit is contained in:
parent
42a9eb9e53
commit
6fcb89f136
|
@ -100,6 +100,9 @@ void CheckStl::stlOutOfBounds()
|
|||
tok = tok->next();
|
||||
}
|
||||
|
||||
if( !tok )
|
||||
return;
|
||||
|
||||
tok = tok->next();
|
||||
if (!num || tok->str() != "{")
|
||||
continue;
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
TEST_CASE(eraseAssign);
|
||||
|
||||
TEST_CASE(pushback1);
|
||||
TEST_CASE(invalidcode);
|
||||
}
|
||||
|
||||
void check(const char code[])
|
||||
|
@ -247,7 +248,14 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:5]: (error) After push_back or push_front, the iterator 'it' may be invalid\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void invalidcode()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" for ( \n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestStl)
|
||||
|
|
Loading…
Reference in New Issue