diff options
author | Brad Linden <brad@lindenlab.com> | 2022-12-12 17:59:34 -0800 |
---|---|---|
committer | Brad Linden <brad@lindenlab.com> | 2022-12-12 17:59:34 -0800 |
commit | eb526fec0aadcaf30363fdfb1e253a609bf83acc (patch) | |
tree | 6071628f41ca793007b645aa30d255044ddbfe43 /indra/llmath/llvolume.cpp | |
parent | c9c611fd12f55ac6d6717ba17139ba61a6db581f (diff) | |
parent | a0c3d69c620a92d73a1008f218680fb4d0ef9255 (diff) |
Merge remote-tracking branch 'origin/main' into DRTVWR-559
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r-- | indra/llmath/llvolume.cpp | 22 |
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()); |