SL-17796 Crash at LLVolumeFace::getVertexData

master
Andrey Kleshchev 2022-07-19 21:08:51 +03:00
parent fcb3b6917c
commit f4e6ccc2c4
1 changed files with 22 additions and 0 deletions

View File

@ -4967,6 +4967,17 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
{
U16 index = mIndices[i];
if (index >= mNumVertices)
{
// invalid index
// replace with a valid index to avoid crashes
index = mNumVertices - 1;
mIndices[i] = index;
// Needs better logging
LL_DEBUGS_ONCE("LLVOLUME") << "Invalid index, substituting" << LL_ENDL;
}
LLVolumeFace::VertexData cv;
getVertexData(index, cv);
@ -5339,6 +5350,17 @@ bool LLVolumeFace::cacheOptimize()
U16 idx = mIndices[i];
U32 tri_idx = i / 3;
if (idx >= mNumVertices)
{
// invalid index
// replace with a valid index to avoid crashes
idx = mNumVertices - 1;
mIndices[i] = idx;
// Needs better logging
LL_DEBUGS_ONCE("LLVOLUME") << "Invalid index, substituting" << LL_ENDL;
}
vertex_data[idx].mTriangles.push_back(&(triangle_data[tri_idx]));
vertex_data[idx].mIdx = idx;
triangle_data[tri_idx].mVertex[i % 3] = &(vertex_data[idx]);