#6724 segmentation fault (invalid code) Token::isAttributeConstructor. Local fix to avoid access to NULL-token
This commit is contained in:
parent
4050d56169
commit
ddc80246c2
|
@ -9177,7 +9177,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
// prototype for constructor is: void func(void);
|
// prototype for constructor is: void func(void);
|
||||||
if (tok->next()->link()->next()->str() == "void") // __attribute__((constructor)) void func() {}
|
if (tok->next()->link()->next()->str() == "void") // __attribute__((constructor)) void func() {}
|
||||||
tok->next()->link()->next()->next()->isAttributeConstructor(true);
|
tok->next()->link()->next()->next()->isAttributeConstructor(true);
|
||||||
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1)) // void func() __attribute__((constructor));
|
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1) && tok->previous()->link()->previous()) // void func() __attribute__((constructor));
|
||||||
tok->previous()->link()->previous()->isAttributeConstructor(true);
|
tok->previous()->link()->previous()->isAttributeConstructor(true);
|
||||||
else // void __attribute__((constructor)) func() {}
|
else // void __attribute__((constructor)) func() {}
|
||||||
tok->next()->link()->next()->isAttributeConstructor(true);
|
tok->next()->link()->next()->isAttributeConstructor(true);
|
||||||
|
@ -9187,7 +9187,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
// prototype for destructor is: void func(void);
|
// prototype for destructor is: void func(void);
|
||||||
if (tok->next()->link()->next()->str() == "void") // __attribute__((destructor)) void func() {}
|
if (tok->next()->link()->next()->str() == "void") // __attribute__((destructor)) void func() {}
|
||||||
tok->next()->link()->next()->next()->isAttributeDestructor(true);
|
tok->next()->link()->next()->next()->isAttributeDestructor(true);
|
||||||
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1)) // void func() __attribute__((destructor));
|
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1) && tok->previous()->link()->previous()) // void func() __attribute__((destructor));
|
||||||
tok->previous()->link()->previous()->isAttributeDestructor(true);
|
tok->previous()->link()->previous()->isAttributeDestructor(true);
|
||||||
else // void __attribute__((destructor)) func() {}
|
else // void __attribute__((destructor)) func() {}
|
||||||
tok->next()->link()->next()->isAttributeDestructor(true);
|
tok->next()->link()->next()->isAttributeDestructor(true);
|
||||||
|
|
|
@ -93,6 +93,7 @@ private:
|
||||||
TEST_CASE(garbageCode52); // #6720
|
TEST_CASE(garbageCode52); // #6720
|
||||||
TEST_CASE(garbageCode53); // #6721
|
TEST_CASE(garbageCode53); // #6721
|
||||||
TEST_CASE(garbageCode54); // #6722
|
TEST_CASE(garbageCode54); // #6722
|
||||||
|
TEST_CASE(garbageCode55); // #6724
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -530,6 +531,10 @@ private:
|
||||||
ASSERT_THROW(checkCode("{ typedef long ((pf) p) (); }"), InternalError);
|
ASSERT_THROW(checkCode("{ typedef long ((pf) p) (); }"), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode55() { // #6724
|
||||||
|
checkCode("() __attribute__((constructor)); { } { }");
|
||||||
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue