#6791 segmentation fault (invalid code) in TokenList::createAst. Fix null pointer access
This commit is contained in:
parent
c047fae53b
commit
ac1f0301c0
|
@ -320,7 +320,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
|
|||
|
||||
std::getline(code, line);
|
||||
|
||||
unsigned int row;
|
||||
unsigned int row=0;
|
||||
std::istringstream fiss(line);
|
||||
if (fiss >> row) {
|
||||
// Update the current line number
|
||||
|
@ -955,6 +955,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
;
|
||||
else if (Token::simpleMatch(tok->astParent(), "(") &&
|
||||
Token::simpleMatch(tok->astParent()->astParent(), "[") &&
|
||||
tok->astParent()->astParent()->astOperand1() &&
|
||||
tok == tok->astParent()->astParent()->astOperand1()->astOperand1())
|
||||
;
|
||||
else
|
||||
|
|
|
@ -130,6 +130,7 @@ private:
|
|||
TEST_CASE(garbageCode88);
|
||||
TEST_CASE(garbageCode89);
|
||||
TEST_CASE(garbageCode90);
|
||||
TEST_CASE(garbageCode91);
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -712,6 +713,10 @@ private:
|
|||
ASSERT_THROW(checkCode("{ } { } typedef int u_array [[ ] ; typedef u_array & u_array_ref] ( ) { } u_array_ref_gbl_obj0"), InternalError); // do not crash
|
||||
}
|
||||
|
||||
void garbageCode91() { // #6791
|
||||
checkCode("typedef __attribute__((vector_size (16))) { return[ (v2df){ } ;] }"); // do not crash
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue