Fix 10582: ValueFlow; wrong known value (#3550)

This commit is contained in:
Paul Fultz II 2021-11-07 00:51:51 -05:00 committed by GitHub
parent 1791457227
commit a50596df72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1748,7 +1748,7 @@ bool isReturnScope(const Token* const endToken, const Library* library, const To
if (!functionScope && Token::simpleMatch(prev->link()->previous(), ") {") &&
Token::simpleMatch(prev->link()->linkAt(-1)->previous(), "switch (") &&
!Token::findsimplematch(prev->link(), "break", prev)) {
return true;
return isReturnScope(prev, library, unknownFunc, functionScope);
}
if (isEscaped(prev->link()->astTop(), functionScope, library))
return true;

View File

@ -3800,6 +3800,15 @@ private:
" do {} while (i++ == 0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #10582
check("static void fun(message_t *message) {\n"
" if (message->length >= 1) {\n"
" switch (data[0]) {}\n"
" }\n"
" uint8_t d0 = message->length > 0 ? data[0] : 0xff;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueSymbolic()