vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

Should Ktx2Header length check be changed? #188

Closed xPaw closed 12 months ago

xPaw commented 1 year ago

https://github.com/vpenades/SharpGLTF/blob/9c6a4c0b4647a4478eba5abb69592b6708f79758/src/SharpGLTF.Core/Memory/MemoryImage.cs#L492-L493

When running in a debugger, I get a IndexOutOfRangeException here on the MemoryMarshal.Cast call. Should the data.Count check be changed from 12 to 48 because of all the integers in the struct?

It works fine due to the try/catch in _IsKtx2Image.

vpenades commented 12 months ago

you're right, It should not use a hardcoded value.

This class is used for basic validation, and at the time of writing I could not find nearly enough examples to work with...