Skip to content

Commit 5a72bed

Browse files
committed
1 parent e4f6d4c commit 5a72bed

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/checkpostfixoperator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void CheckPostfixOperator::postfixOperator()
5555
else if (tok->strAt(-2) == ",")
5656
{
5757
int i(1);
58-
while (tok->strAt(i) != ")")
58+
while (tok->strAt(i) != ")" && tok->tokAt(i) != 0)
5959
{
6060
if (tok->strAt(i) == ";")
6161
{

test/testpostfixoperator.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class TestPostfixOperator : public TestFixture
7070
TEST_CASE(testiterator);
7171
TEST_CASE(test2168);
7272
TEST_CASE(pointer); // #2321 - postincrement of pointer is OK
73+
TEST_CASE(testHangWithInvalidCode); // #2847 - cppcheck hangs with 100% cpu load
74+
}
75+
76+
void testHangWithInvalidCode()
77+
{
78+
check("a,b--\n");
79+
ASSERT_EQUALS("", errout.str());
7380
}
7481

7582
void testsimple()

0 commit comments

Comments
 (0)