summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-07-19 21:08:51 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-07-19 21:08:51 +0300
commitf4e6ccc2c4a79e77dc338f8caec6510751c3ee83 (patch)
tree52f6ba1e8a91a1d1f9b01b76f8238d418c2afc39
parentfcb3b6917c852779a846673bd8b35cdc2fda6bb7 (diff)
SL-17796 Crash at LLVolumeFace::getVertexData
-rw-r--r--indra/llmath/llvolume.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 5099920f32..cc3f3acbad 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -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]);