Skip to content

Commit db5c8df

Browse files
authored
Expand ReadSparseBinaryData index check to check for overflow (#89)
* Modified check to verify that currentIndex value isn't the result of an overflow * Removed an unnecessary curly brace * Modified fix
1 parent d806b75 commit db5c8df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

GLTFSDK/Inc/GLTFSDK/GLTFResourceReader.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ namespace Microsoft
389389

390390
for (size_t i = 0; i < indices.size(); i++)
391391
{
392-
// Verify provided index is valid before storing value
393-
if ((indices[i] * typeCount + (typeCount - 1)) < static_cast<I>(baseData.size()))
392+
assert(baseData.size() == accessor.count * typeCount);
393+
static_assert(sizeof(I) <= sizeof(size_t), "sizeof(I) < sizeof(size_t)");
394+
if (0 <= indices[i] && static_cast<size_t>(indices[i]) < accessor.count)
394395
{
395396
for (size_t j = 0; j < typeCount; j++)
396397
{

0 commit comments

Comments
 (0)