Merge pull request #148 from JustRamires/master

Fixed segmentation fault in SymbolDatabase::SymbolDatabase(Ticket #4892)
This commit is contained in:
Daniel Marjamäki 2013-07-09 02:55:46 -07:00
commit 4106972fdc
3 changed files with 15 additions and 1 deletions

View File

@ -742,6 +742,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
scope = &(*it);
if (!scope->definedType) {
_blankTypes.push_back(Type());
scope->definedType = &_blankTypes.back();
}
if (scope->isClassOrStruct() && scope->definedType->needInitialization == Type::Unknown) {
// check for default constructor
bool hasDefaultConstructor = false;
@ -799,7 +804,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
if (scope->definedType->needInitialization == Type::Unknown)
unknowns++;
}
} else if (scope->type == Scope::eUnion && scope->definedType && scope->definedType->needInitialization == Type::Unknown)
} else if (scope->type == Scope::eUnion && scope->definedType->needInitialization == Type::Unknown)
scope->definedType->needInitialization = Type::True;
}

View File

@ -730,6 +730,9 @@ private:
/** variable symbol table */
std::vector<const Variable *> _variableList;
/** list for missing types */
std::list<Type> _blankTypes;
};
#endif

View File

@ -193,6 +193,7 @@ private:
TEST_CASE(symboldatabase33); // ticket #4682 (false negatives)
TEST_CASE(symboldatabase34); // ticket #4694 (segmentation fault)
TEST_CASE(symboldatabase35); // ticket #4806 (segmentation fault)
TEST_CASE(symboldatabase36); // ticket #4892 (segmentation fault)
TEST_CASE(isImplicitlyVirtual);
@ -1513,6 +1514,11 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase36() { // ticket #4892
check("void struct ( ) { if ( 1 ) } int main ( ) { }");
ASSERT_EQUALS("", errout.str());
}
void isImplicitlyVirtual() {
{
GET_SYMBOL_DB("class Base {\n"