summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2022-12-12 17:59:34 -0800
committerBrad Linden <brad@lindenlab.com>2022-12-12 17:59:34 -0800
commiteb526fec0aadcaf30363fdfb1e253a609bf83acc (patch)
tree6071628f41ca793007b645aa30d255044ddbfe43 /indra/llmath/llvolume.cpp
parentc9c611fd12f55ac6d6717ba17139ba61a6db581f (diff)
parenta0c3d69c620a92d73a1008f218680fb4d0ef9255 (diff)
Merge remote-tracking branch 'origin/main' into DRTVWR-559
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-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 a0f3b1463b..33659e6b81 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5070,6 +5070,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);
@@ -5452,6 +5463,17 @@ struct MikktData
n[i].normalize();
tc[i].set(face->mTexCoords[idx]);
+ if (idx >= face->mNumVertices)
+ {
+ // invalid index
+ // replace with a valid index to avoid crashes
+ idx = face->mNumVertices - 1;
+ face->mIndices[i] = idx;
+
+ // Needs better logging
+ LL_DEBUGS_ONCE("LLVOLUME") << "Invalid index, substituting" << LL_ENDL;
+ }
+
if (face->mWeights)
{
w[i].set(face->mWeights[idx].getF32ptr());