diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2023-01-24 20:15:43 +0000 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2023-01-24 20:15:43 +0000 |
commit | 3375e1a7b518eb40eb1814ced745266ce3a54ce7 (patch) | |
tree | f2b1281ec664e72615d11c6bd35a944d8897fa50 /indra/llmath/llvolume.cpp | |
parent | ce5ac93883b71b6abf8cffa35204541e257c6b02 (diff) | |
parent | 111fc04e5df60e1d509b9ec80a1340bab4383cce (diff) |
Merge branch 'DRTVWR-567' of ssh://github.com/secondlife/viewer into DRTVWR-567
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 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]); |