summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorCallum Prentice <callum@mbp.localdomain>2022-12-12 11:13:10 -0800
committerCallum Prentice <callum@mbp.localdomain>2022-12-12 11:13:10 -0800
commitf7838ca17c7e4a5a595f5cb898c70a18be4c9cd9 (patch)
treefa2dc9c6d34a0c6e7de54df74c032f611a0bd747 /indra/llmath
parent395a60a83e954e9bcbb44dc6f1a49319b2d628b7 (diff)
parenta0c3d69c620a92d73a1008f218680fb4d0ef9255 (diff)
Merge branch 'main' into DRTVWR-568
Diffstat (limited to 'indra/llmath')
-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 f43d07ce5e..be25592d54 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5013,6 +5013,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);
@@ -5385,6 +5396,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]);