Fix crash in cbmc detected with daca@home

This commit is contained in:
Daniel Marjamäki 2020-09-24 20:48:26 +02:00
parent 801cc8d331
commit 093ff58f5f
2 changed files with 11 additions and 0 deletions

View File

@ -49,6 +49,9 @@ void CheckAssert::assertWithSideEffects()
const Token *endTok = tok->next()->link();
for (const Token* tmp = tok->next(); tmp != endTok; tmp = tmp->next()) {
if (Token::simpleMatch(tmp, "sizeof ("))
tmp = tmp->linkAt(1);
checkVariableAssignment(tmp, tok->scope());
if (tmp->tokType() != Token::eFunction)

View File

@ -51,6 +51,7 @@ private:
TEST_CASE(functionCallInAssert);
TEST_CASE(memberFunctionCallInAssert);
TEST_CASE(safeFunctionCallInAssert);
TEST_CASE(crash);
}
@ -236,6 +237,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void crash() {
check("void foo() {\n"
" assert(sizeof(struct { int a[x++]; })==sizeof(int));\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestAssert)