#5875 clang ubsan errors: lib/checkassignif.cpp:58:34: runtime error: member call on null pointer of type 'Token'
This commit is contained in:
parent
66ad3c97b9
commit
98ea1397b3
|
@ -55,7 +55,7 @@ void CheckAssignIf::assignIf()
|
|||
const Token *endToken = Token::findsimplematch(tok, ";");
|
||||
|
||||
// Casting address
|
||||
if (Token::Match(endToken->tokAt(-4), "* ) & %any% ;"))
|
||||
if (endToken && Token::Match(endToken->tokAt(-4), "* ) & %any% ;"))
|
||||
endToken = nullptr;
|
||||
|
||||
if (endToken && Token::Match(endToken->tokAt(-2), "[&|] %num% ;")) {
|
||||
|
|
|
@ -38,6 +38,7 @@ private:
|
|||
TEST_CASE(compare); // mismatching LHS/RHS in comparison
|
||||
TEST_CASE(multicompare); // mismatching comparisons
|
||||
TEST_CASE(duplicateIf); // duplicate conditions in if and else-if
|
||||
TEST_CASE(invalidMissingSemicolon); // crash as of #5867
|
||||
}
|
||||
|
||||
void check(const char code[]) {
|
||||
|
@ -378,6 +379,15 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void invalidMissingSemicolon()
|
||||
{
|
||||
// simply survive - a syntax error would be even better
|
||||
check("void f(int x) {\n"
|
||||
" x = 42\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestAssignIf)
|
||||
|
|
Loading…
Reference in New Issue