FIX: array bound happen in TriangleSelector::deserialize

Jira: STUDIO-5170
Change-Id: I92b72a887845b462fad208f13607293b44d3d333
This commit is contained in:
zhou.xu 2023-11-27 16:02:12 +08:00 committed by Lane.Wei
parent 742047a642
commit 538c6faebb
1 changed files with 6 additions and 1 deletions

View File

@ -1703,7 +1703,12 @@ void TriangleSelector::deserialize(const std::pair<std::vector<std::pair<int, in
{
if (needs_reset)
reset(); // dump any current state
for (auto [triangle_id, ibit] : data.first) {
if (triangle_id >= int(m_triangles.size())) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "array bound:error:triangle_id >= int(m_triangles.size())";
return;
}
}
// Reserve number of triangles as if each triangle was saved with 4 bits.
// With MMU painting this estimate may be somehow low, but better than nothing.
m_triangles.reserve(std::max(m_mesh.its.indices.size(), data.second.size() / 4));