Fix #2847, cppcheck hangs with 100% cpu load

http://sourceforge.net/apps/trac/cppcheck/ticket/2847
This commit is contained in:
Reijo Tomperi 2011-06-22 14:09:42 +03:00
parent e4f6d4c987
commit 5a72bed064
2 changed files with 8 additions and 1 deletions

View File

@ -55,7 +55,7 @@ void CheckPostfixOperator::postfixOperator()
else if (tok->strAt(-2) == ",")
{
int i(1);
while (tok->strAt(i) != ")")
while (tok->strAt(i) != ")" && tok->tokAt(i) != 0)
{
if (tok->strAt(i) == ";")
{

View File

@ -70,6 +70,13 @@ private:
TEST_CASE(testiterator);
TEST_CASE(test2168);
TEST_CASE(pointer); // #2321 - postincrement of pointer is OK
TEST_CASE(testHangWithInvalidCode); // #2847 - cppcheck hangs with 100% cpu load
}
void testHangWithInvalidCode()
{
check("a,b--\n");
ASSERT_EQUALS("", errout.str());
}
void testsimple()