@@ -35,8 +35,8 @@ namespace
3535 _In_reads_(nFaces * 3 ) const uint32_t* adjacency,
3636 const std::vector<std::pair<size_t, size_t>>& subsets)
3737 {
38- if (!indices || !nFaces || ! adjacency || subsets. empty () )
39- return E_INVALIDARG ;
38+ if (!indices || !adjacency)
39+ return E_POINTER ;
4040
4141 // Convert adjacency to 'physical' adjacency
4242 mPhysicalNeighbors .reset (new (std::nothrow) neighborInfo[nFaces]);
@@ -163,15 +163,12 @@ namespace
163163 _In_reads_ (nFaces * 3 ) const index_t* indices, size_t nFaces,
164164 size_t faceOffset, size_t faceCount) noexcept
165165 {
166- if (!faceCount || ! indices || !nFaces )
167- return E_INVALIDARG ;
166+ if (!indices || !mListElements )
167+ return E_POINTER ;
168168
169- if (faceCount > mMaxSubset )
169+ if (!faceCount || faceCount > mMaxSubset )
170170 return E_UNEXPECTED;
171171
172- if (!mListElements )
173- return E_POINTER;
174-
175172 if ((uint64_t (faceOffset) + uint64_t (faceCount)) >= UINT32_MAX)
176173 return HRESULT_E_ARITHMETIC_OVERFLOW;
177174
@@ -457,7 +454,7 @@ namespace
457454 HRESULT initialize (uint32_t cacheSize) noexcept
458455 {
459456 if (!cacheSize)
460- return E_INVALIDARG ;
457+ return E_UNEXPECTED ;
461458
462459 mFIFO .reset (new (std::nothrow) uint32_t [cacheSize]);
463460 if (!mFIFO )
@@ -514,8 +511,8 @@ namespace
514511 _Out_writes_(nFaces) uint32_t* faceRemap)
515512 {
516513 auto subsets = ComputeSubsets (attributes, nFaces);
517-
518- assert (!subsets. empty ()) ;
514+ if (subsets. empty ())
515+ return E_UNEXPECTED ;
519516
520517 mesh_status<index_t > status;
521518 HRESULT hr = status.initialize (indices, nFaces, adjacency, subsets);
@@ -592,8 +589,8 @@ namespace
592589 uint32_t vertexCache, uint32_t restart)
593590 {
594591 auto subsets = ComputeSubsets (attributes, nFaces);
595-
596- assert (!subsets. empty ()) ;
592+ if (subsets. empty ())
593+ return E_UNEXPECTED ;
597594
598595 mesh_status<index_t > status;
599596 HRESULT hr = status.initialize (indices, nFaces, adjacency, subsets);
0 commit comments