#6846 segmentation fault (invalid code) in CheckClass::hasAssignSelf

This commit is contained in:
Alexander Mai 2015-07-20 19:04:34 +02:00
parent c0880c8d79
commit defee734f5
2 changed files with 7 additions and 0 deletions

View File

@ -1424,6 +1424,8 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope) const
bool CheckClass::hasAssignSelf(const Function *func, const Token *rhs)
{
if (!rhs)
return false;
const Token *last = func->functionScope->classEnd;
for (const Token *tok = func->functionScope->classStart; tok && tok != last; tok = tok->next()) {
if (Token::simpleMatch(tok, "if (")) {

View File

@ -141,6 +141,7 @@ private:
TEST_CASE(garbageCode99);
TEST_CASE(garbageCode100);
TEST_CASE(garbageCode101); // #6835
TEST_CASE(garbageCode102); // #6846
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -799,6 +800,10 @@ private:
checkCode("template < class =( , ) X = 1> struct A {}; A<void> a;");
}
void garbageCode102() { // #6846
checkCode("struct Object { ( ) ; Object & operator= ( Object ) { ( ) { } if ( this != & b ) } }");
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"