#5703 - Segfault recursive loop - Patch by zingsheim

This commit is contained in:
Alexander Mai 2014-04-21 22:13:02 +02:00
parent 623e5db0b2
commit 2c3807f089
2 changed files with 11 additions and 1 deletions

View File

@ -181,7 +181,7 @@ void CheckExceptionSafety::checkCatchExceptionByValue()
static const Token * functionThrowsRecursive(const Function * function, std::set<const Function *> & recursive)
{
// check for recursion and bail if found
if (recursive.find(function) != recursive.end())
if (!recursive.insert(function).second)
return nullptr;
if (!function->functionScope)

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(nothrowThrow);
TEST_CASE(unhandledExceptionSpecification); // #4800
TEST_CASE(nothrowAttributeThrow);
TEST_CASE(nothrowAttributeThrow2); // #5703
}
void check(const char code[], bool inconclusive = false) {
@ -372,6 +373,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nothrowAttributeThrow2() {
check("class foo {\n"
" void copyMemberValues() throw () {\n"
" copyMemberValues();\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestExceptionSafety)