Skip to content

Commit 8e4441e

Browse files
authored
Fix OOB Writing issue when using sparse accessors (#78)
* Fix OOB issue * Moved check to outer loop
1 parent dfce430 commit 8e4441e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

GLTFSDK/Inc/GLTFSDK/GLTFResourceReader.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,13 @@ namespace Microsoft
389389

390390
for (size_t i = 0; i < indices.size(); i++)
391391
{
392-
for (size_t j = 0; j < typeCount; j++)
392+
// Verify provided index is valid before storing value
393+
if ((indices[i] * typeCount + (typeCount - 1)) < baseData.size())
393394
{
394-
baseData[indices[i] * typeCount + j] = values[i * typeCount + j];
395+
for (size_t j = 0; j < typeCount; j++)
396+
{
397+
baseData[indices[i] * typeCount + j] = values[i * typeCount + j];
398+
}
395399
}
396400
}
397401
}

0 commit comments

Comments
 (0)