#7236 segmentation fault (invalid code) in ValueFlow::setValues. #7237 segmentation fault (invalid code) in Tokenizer::setVarIdClassDeclaration
This commit is contained in:
parent
081f443b2a
commit
e9635fd393
|
@ -2618,6 +2618,8 @@ void Tokenizer::setVarIdClassDeclaration(Token * const startToken,
|
|||
if (indentlevel > 0 || initList) {
|
||||
if (Token::Match(tok->previous(), "::|.") && tok->strAt(-2) != "this" && !Token::simpleMatch(tok->tokAt(-5), "( * this ) ."))
|
||||
continue;
|
||||
if (!tok->next())
|
||||
syntaxError(nullptr); // #7237 invalid code
|
||||
if (tok->next()->str() == "::") {
|
||||
if (tok->str() == className)
|
||||
tok = tok->tokAt(2);
|
||||
|
|
|
@ -1384,6 +1384,8 @@ static bool valueFlowForward(Token * const startToken,
|
|||
tok2 = tok2->next();
|
||||
}
|
||||
|
||||
if (!tok2) // invalid code #7236
|
||||
return false;
|
||||
if (tok2->varId() == varid) {
|
||||
// bailout: assignment
|
||||
if (Token::Match(tok2->previous(), "!!* %name% %op%") && tok2->next()->isAssignmentOp()) {
|
||||
|
|
|
@ -214,6 +214,8 @@ private:
|
|||
TEST_CASE(garbageCode163); // #7228
|
||||
TEST_CASE(garbageCode164); // #7234
|
||||
TEST_CASE(garbageCode165); // #7235
|
||||
TEST_CASE(garbageCode166); // #7236
|
||||
TEST_CASE(garbageCode167); // #7237
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
TEST_CASE(garbageAST);
|
||||
|
@ -1410,6 +1412,16 @@ private:
|
|||
//7235
|
||||
checkCode("for(;..)", false);
|
||||
}
|
||||
|
||||
void garbageCode166() {
|
||||
//7236
|
||||
checkCode("d a(){f s=0()8[]s?():0}*()?:0", false);
|
||||
}
|
||||
|
||||
void garbageCode167() {
|
||||
//7237
|
||||
checkCode("class D00i000{:D00i000::}i", false);
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestGarbage)
|
||||
|
|
Loading…
Reference in New Issue