#5641 fix crash within CheckClass::initializeVarList()

This commit is contained in:
Alexander Mai 2014-04-04 22:13:51 +02:00
parent 0788e64eb8
commit 173a2e9ea2
2 changed files with 12 additions and 1 deletions

View File

@ -435,7 +435,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
bool initList = func.isConstructor();
const Token *ftok = func.arg->link()->next();
int level = 0;
for (; ftok != func.functionScope->classEnd; ftok = ftok->next()) {
for (; ftok && ftok != func.functionScope->classEnd; ftok = ftok->next()) {
// Class constructor.. initializing variables like this
// clKalle::clKalle() : var(value) { }
if (initList) {

View File

@ -162,6 +162,7 @@ private:
TEST_CASE(uninitVarOperatorEqual); // ticket #2415
TEST_CASE(uninitVarPointer); // ticket #3801
TEST_CASE(uninitConstVar);
TEST_CASE(constructors_crash1); // ticket #5641
}
@ -2901,6 +2902,16 @@ private:
"};");
ASSERT_EQUALS("", errout.str());
}
// Ticket #5641 "Regression. Crash for 'C() _STLP_NOTHROW {}'"
void constructors_crash1() {
check("class C {\n"
"public:\n"
" C() _STLP_NOTHROW {}\n"
" C(const C&) _STLP_NOTHROW {}\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestConstructors)