提交 6ca798a3 编写于 作者: P proller 提交者: alexey-milovidov

Fix infinite loop in dictGetHierarchy if id chain looped

上级 7937903d
......@@ -138,6 +138,11 @@ void CacheDictionary::isInImpl(
out[out_idx] = 1;
}
/// Found intermediate parent, add this value to search at next loop iteration
else if (children[new_children_idx] == parents[parents_idx])
{
// Loop detected
out[out_idx] = 0;
}
else
{
children[new_children_idx] = parents[parents_idx];
......
......@@ -1431,9 +1431,16 @@ private:
if (0 == id)
continue;
auto & hierarchy = hierarchies[i];
//Checking for loop
if (std::find(std::begin(hierarchy), std::end(hierarchy), id) != std::end(hierarchy))
continue;
all_zeroes = false;
/// place id at it's corresponding place
hierarchies[i].push_back(id);
hierarchy.push_back(id);
++total_count;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册