Skip to content

Commit 37b358e

Browse files
authored
Bounds-check sentinel and out-of-range indices in Validate() (#317)
1 parent 9874699 commit 37b358e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎DirectXMesh/DirectXMeshValidate.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ namespace
197197
if (k == UNUSED32)
198198
continue;
199199

200-
assert(k < nFaces);
200+
if (k >= nFaces)
201+
{
202+
result = false;
203+
continue;
204+
}
201205

202206
const uint32_t edge = find_edge<uint32_t>(&adjacency[k * 3], uint32_t(face));
203207
if (edge >= 3)
@@ -326,6 +330,8 @@ namespace
326330
faceSeen[curFace * 3 + curPoint] = true;
327331

328332
uint32_t j = indices[curFace * 3 + curPoint];
333+
if (j == index_t(-1))
334+
continue;
329335

330336
if (faceIds[j] == index_t(-1))
331337
{

0 commit comments

Comments
 (0)