Skip to content

Commit

Permalink
Expand ReadSparseBinaryData index check to check for overflow (#89)
Browse files Browse the repository at this point in the history
* Modified check to verify that currentIndex value isn't the result of an overflow

* Removed an unnecessary curly brace

* Modified fix
  • Loading branch information
PolygonalSun authored Nov 5, 2021
1 parent d806b75 commit db5c8df
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions GLTFSDK/Inc/GLTFSDK/GLTFResourceReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ namespace Microsoft

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

0 comments on commit db5c8df

Please sign in to comment.