Fixed crash caused by endless recursion in redundant assignments check
This commit is contained in:
parent
ff4cf68338
commit
807f62520c
|
@ -622,15 +622,11 @@ static void eraseNotLocalArg(std::map<unsigned int, const Token*>& container, co
|
||||||
|
|
||||||
static void eraseMemberAssignments(const unsigned int varId, std::map<unsigned int, std::set<unsigned int> > &membervars, std::map<unsigned int, const Token*> &varAssignments)
|
static void eraseMemberAssignments(const unsigned int varId, std::map<unsigned int, std::set<unsigned int> > &membervars, std::map<unsigned int, const Token*> &varAssignments)
|
||||||
{
|
{
|
||||||
if (varAssignments.empty() || membervars.empty())
|
|
||||||
return;
|
|
||||||
const std::map<unsigned int, std::set<unsigned int> >::const_iterator it = membervars.find(varId);
|
const std::map<unsigned int, std::set<unsigned int> >::const_iterator it = membervars.find(varId);
|
||||||
if (it != membervars.end()) {
|
if (it != membervars.end()) {
|
||||||
const std::set<unsigned int> &v = it->second;
|
const std::set<unsigned int> &v = it->second;
|
||||||
for (std::set<unsigned int>::const_iterator vit = v.begin(); vit != v.end(); ++vit) {
|
for (std::set<unsigned int>::const_iterator vit = v.begin(); vit != v.end(); ++vit)
|
||||||
varAssignments.erase(*vit);
|
varAssignments.erase(*vit);
|
||||||
eraseMemberAssignments(*vit, membervars, varAssignments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6392,6 +6392,18 @@ private:
|
||||||
" ab->b = 2;\n"
|
" ab->b = 2;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// don't crash
|
||||||
|
check("struct data {\n"
|
||||||
|
" struct { int i; } fc;\n"
|
||||||
|
"};\n"
|
||||||
|
"struct state {\n"
|
||||||
|
" struct data d[123];\n"
|
||||||
|
"};\n"
|
||||||
|
"void func(struct state *s) {\n"
|
||||||
|
" s->foo[s->x++] = 2;\n"
|
||||||
|
" s->d[1].fc.i++;\n"
|
||||||
|
"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void redundantMemWrite() {
|
void redundantMemWrite() {
|
||||||
|
|
Loading…
Reference in New Issue