Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DirectXMesh/DirectXMeshAdjacency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ namespace
const uint32_t v2 = pointRep[i1];
const uint32_t v3 = pointRep[i2];

if (v1 >= nVerts
|| v2 >= nVerts
|| v3 >= nVerts)
return E_UNEXPECTED;

// filter out degenerate triangles
if (v1 == v2 || v1 == v3 || v2 == v3)
continue;
Expand Down
8 changes: 8 additions & 0 deletions DirectXMesh/DirectXMeshGSAdjacency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ namespace
{
indicesAdj[outputi] = indices[face * 3 + ((point + 2) % 3)];
}
else if (a >= nFaces)
{
return E_UNEXPECTED;
}
else
{
uint32_t v1 = indices[face * 3 + point];
Expand All @@ -82,6 +86,10 @@ namespace
v1 = pointRep[v1];
v2 = pointRep[v2];

if (((v1 != UNUSED32) && (v1 >= nVerts))
|| ((v2 != UNUSED32) && (v2 >= nVerts)))
return E_UNEXPECTED;

uint32_t vOther = UNUSED32;

// find other vertex
Expand Down
3 changes: 3 additions & 0 deletions DirectXMesh/DirectXMeshOptimizeTVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ namespace

if (neighbor != UNUSED32)
{
if (neighbor >= nFaces)
return E_UNEXPECTED;

if ((neighbor < faceOffset) || (neighbor >= faceMax)
|| (neighbor == adjacency[face * 3 + ((n + 1) % 3)])
|| (neighbor == adjacency[face * 3 + ((n + 2) % 3)]))
Expand Down
16 changes: 8 additions & 8 deletions DirectXMesh/DirectXMeshRemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace
}
}
else
return E_FAIL;
return E_UNEXPECTED;
}

return S_OK;
Expand Down Expand Up @@ -667,7 +667,7 @@ HRESULT DirectX::FinalizeVB(
}
else if (src >= newVerts)
{
return E_FAIL;
return E_UNEXPECTED;
}
else if (src < nVerts)
{
Expand Down Expand Up @@ -768,7 +768,7 @@ HRESULT DirectX::FinalizeVBAndPointReps(
if (vertexRemap[j] != UNUSED32)
{
if (vertexRemap[j] >= newVerts)
return E_INVALIDARG;
return E_UNEXPECTED;

vertexRemapInverse[vertexRemap[j]] = j;
}
Expand All @@ -790,7 +790,11 @@ HRESULT DirectX::FinalizeVBAndPointReps(

for (size_t i = 0; i < nDupVerts; ++i)
{
pointRep[i + nVerts] = prin[dupVerts[i]];
uint32_t pr = dupVerts[i];
if (pr >= nDupVerts)
return E_UNEXPECTED;

pointRep[i + nVerts] = prin[pr];
}

for (size_t j = 0; j < newVerts; ++j)
Expand All @@ -801,10 +805,6 @@ HRESULT DirectX::FinalizeVBAndPointReps(
{
// remap entry is unused
}
else if (src >= newVerts)
{
return E_FAIL;
}
else if (src < nVerts)
{
memcpy(dptr, sptr + src * stride, stride);
Expand Down
3 changes: 3 additions & 0 deletions DirectXMesh/DirectXMeshUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ namespace
if (indices[j] == index_t(-1))
continue;

if (indices[j] >= nVerts)
return;

bool found = false;

for (size_t ptr = 0; ptr < cacheSize; ++ptr)
Expand Down
3 changes: 3 additions & 0 deletions DirectXMesh/DirectXMeshWeldVertices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ namespace
if (i == index_t(-1))
continue;

if (i >= nVerts)
return E_UNEXPECTED;

indices[j] = index_t(vertexRemapInverse[i]);
}

Expand Down
Loading