Fix crash in cbmc detected with daca@home
This commit is contained in:
parent
801cc8d331
commit
093ff58f5f
|
@ -49,6 +49,9 @@ void CheckAssert::assertWithSideEffects()
|
||||||
|
|
||||||
const Token *endTok = tok->next()->link();
|
const Token *endTok = tok->next()->link();
|
||||||
for (const Token* tmp = tok->next(); tmp != endTok; tmp = tmp->next()) {
|
for (const Token* tmp = tok->next(); tmp != endTok; tmp = tmp->next()) {
|
||||||
|
if (Token::simpleMatch(tmp, "sizeof ("))
|
||||||
|
tmp = tmp->linkAt(1);
|
||||||
|
|
||||||
checkVariableAssignment(tmp, tok->scope());
|
checkVariableAssignment(tmp, tok->scope());
|
||||||
|
|
||||||
if (tmp->tokType() != Token::eFunction)
|
if (tmp->tokType() != Token::eFunction)
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
TEST_CASE(functionCallInAssert);
|
TEST_CASE(functionCallInAssert);
|
||||||
TEST_CASE(memberFunctionCallInAssert);
|
TEST_CASE(memberFunctionCallInAssert);
|
||||||
TEST_CASE(safeFunctionCallInAssert);
|
TEST_CASE(safeFunctionCallInAssert);
|
||||||
|
TEST_CASE(crash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,6 +237,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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)
|
REGISTER_TEST(TestAssert)
|
||||||
|
|
Loading…
Reference in New Issue