diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 431c51e21..c81af18cf 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -626,9 +626,12 @@ static void eraseMemberAssignments(const unsigned int varId, std::map >::const_iterator it = membervars.find(varId); if (it != membervars.end()) { - const std::set &v = it->second; - for (std::set::const_iterator vit = v.begin(); vit != v.end(); ++vit) + const std::set v = it->second; + for (std::set::const_iterator vit = v.begin(); vit != v.end(); ++vit) { varAssignments.erase(*vit); + if (*vit != varId) + eraseMemberAssignments(*vit, membervars, varAssignments); + } } } diff --git a/test/testother.cpp b/test/testother.cpp index d6491de8d..8ab7516f4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6417,6 +6417,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void f(struct AB *ab) {\n" // # + " ab->data->x = 1;\n" + " ab = &ab1;\n" + " ab->data->x = 2;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + // don't crash check("struct data {\n" " struct { int i; } fc;\n"