Skip to content

Commit a50596d

Browse files
authored
Fix 10582: ValueFlow; wrong known value (#3550)
1 parent 1791457 commit a50596d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ bool isReturnScope(const Token* const endToken, const Library* library, const To
17481748
if (!functionScope && Token::simpleMatch(prev->link()->previous(), ") {") &&
17491749
Token::simpleMatch(prev->link()->linkAt(-1)->previous(), "switch (") &&
17501750
!Token::findsimplematch(prev->link(), "break", prev)) {
1751-
return true;
1751+
return isReturnScope(prev, library, unknownFunc, functionScope);
17521752
}
17531753
if (isEscaped(prev->link()->astTop(), functionScope, library))
17541754
return true;

test/testcondition.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,6 +3800,15 @@ class TestCondition : public TestFixture {
38003800
" do {} while (i++ == 0);\n"
38013801
"}\n");
38023802
ASSERT_EQUALS("", errout.str());
3803+
3804+
// #10582
3805+
check("static void fun(message_t *message) {\n"
3806+
" if (message->length >= 1) {\n"
3807+
" switch (data[0]) {}\n"
3808+
" }\n"
3809+
" uint8_t d0 = message->length > 0 ? data[0] : 0xff;\n"
3810+
"}\n");
3811+
ASSERT_EQUALS("", errout.str());
38033812
}
38043813

38053814
void alwaysTrueSymbolic()

0 commit comments

Comments
 (0)