#6792 segmentation fault (invalid code) in TemplateSimplifier::templateParameters. Avoid null pointer access
This commit is contained in:
parent
ac1f0301c0
commit
e75662aaf1
|
@ -292,6 +292,10 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
|
|||
|
||||
// Function pointer or prototype..
|
||||
while (Token::Match(tok, "(|[")) {
|
||||
if (!tok->link()) {
|
||||
syntaxError(tok);
|
||||
return 0;
|
||||
}
|
||||
tok = tok->link()->next();
|
||||
while (Token::Match(tok, "const|volatile")) // Ticket #5786: Skip function cv-qualifiers
|
||||
tok = tok->next();
|
||||
|
|
|
@ -131,6 +131,7 @@ private:
|
|||
TEST_CASE(garbageCode89);
|
||||
TEST_CASE(garbageCode90);
|
||||
TEST_CASE(garbageCode91);
|
||||
TEST_CASE(garbageCode92);
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -717,6 +718,10 @@ private:
|
|||
checkCode("typedef __attribute__((vector_size (16))) { return[ (v2df){ } ;] }"); // do not crash
|
||||
}
|
||||
|
||||
void garbageCode92() { // #6792
|
||||
ASSERT_THROW(checkCode("template < typename _Tp ( ( ) ; _Tp ) , decltype > { } { ( ) ( ) }"), InternalError); // 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