#6846 segmentation fault (invalid code) in CheckClass::hasAssignSelf
This commit is contained in:
parent
c0880c8d79
commit
defee734f5
|
@ -1424,6 +1424,8 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope) const
|
||||||
|
|
||||||
bool CheckClass::hasAssignSelf(const Function *func, const Token *rhs)
|
bool CheckClass::hasAssignSelf(const Function *func, const Token *rhs)
|
||||||
{
|
{
|
||||||
|
if (!rhs)
|
||||||
|
return false;
|
||||||
const Token *last = func->functionScope->classEnd;
|
const Token *last = func->functionScope->classEnd;
|
||||||
for (const Token *tok = func->functionScope->classStart; tok && tok != last; tok = tok->next()) {
|
for (const Token *tok = func->functionScope->classStart; tok && tok != last; tok = tok->next()) {
|
||||||
if (Token::simpleMatch(tok, "if (")) {
|
if (Token::simpleMatch(tok, "if (")) {
|
||||||
|
|
|
@ -141,6 +141,7 @@ private:
|
||||||
TEST_CASE(garbageCode99);
|
TEST_CASE(garbageCode99);
|
||||||
TEST_CASE(garbageCode100);
|
TEST_CASE(garbageCode100);
|
||||||
TEST_CASE(garbageCode101); // #6835
|
TEST_CASE(garbageCode101); // #6835
|
||||||
|
TEST_CASE(garbageCode102); // #6846
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -799,6 +800,10 @@ private:
|
||||||
checkCode("template < class =( , ) X = 1> struct A {}; A<void> a;");
|
checkCode("template < class =( , ) X = 1> struct A {}; A<void> a;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode102() { // #6846
|
||||||
|
checkCode("struct Object { ( ) ; Object & operator= ( Object ) { ( ) { } if ( this != & b ) } }");
|
||||||
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue