Skip to content

Commit 7893209

Browse files
committed
Fixed crash on garbage code danmar#6106
1 parent 9733a75 commit 7893209

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/valueflow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,8 @@ static void valueFlowForLoop(TokenList *tokenlist, ErrorLogger *errorLogger, con
14131413
continue;
14141414

14151415
Token * const bodyStart = tok->linkAt(1)->next();
1416+
if (!bodyStart->link() || bodyStart->str() != "{")
1417+
continue;
14161418

14171419
unsigned int varid(0);
14181420
MathLib::bigint num1(0), num2(0), numAfter(0);

test/testvalueflow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,10 @@ class TestValueFlow : public TestFixture {
12631263
" (foo(s, , 2, , , 5, , 7)) abort()\n"
12641264
"}\n";
12651265
ASSERT_THROW(valueOfTok(code, "*"), InternalError);
1266+
1267+
// #6106
1268+
code = " f { int i ; b2 , [ ] ( for ( i = 0 ; ; ) ) }";
1269+
valueOfTok(code, "*");
12661270
}
12671271
};
12681272

0 commit comments

Comments
 (0)