#6737 Avoid segfault on garbage code inside Type::initBaseInfo. Disable test TestGarbage::garbageCode58() for #6732 since it triggers memory corruption still

This commit is contained in:
amai2012 2015-06-02 18:28:43 +02:00
parent 0a148a9433
commit 7895f1c2bb
2 changed files with 8 additions and 2 deletions

View File

@ -1954,7 +1954,8 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
else if (tok->str() == "struct")
base.access = Public;
}
if (!tok2)
return nullptr;
if (tok2->str() == "virtual") {
base.isVirtual = true;
tok2 = tok2->next();

View File

@ -99,6 +99,7 @@ private:
TEST_CASE(garbageCode58); // #6732
TEST_CASE(garbageCode59); // #6735
TEST_CASE(garbageCode60); // #6736
TEST_CASE(garbageCode61);
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -549,7 +550,7 @@ private:
}
void garbageCode58() { // #6732
ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
//ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
}
void garbageCode59() { // #6735
@ -560,6 +561,10 @@ private:
ASSERT_THROW(checkCode("{ } { } typedef int int_array[]; int_array &right ="), InternalError);
}
void garbageCode61() { // #6737
ASSERT_THROW(checkCode("{ (const U&) }; { }; { }; struct U : virtual public"), InternalError);
}
void garbageValueFlow() {
// #6089