vpenades/SharpGLTF

Should Ktx2Header length check be changed?

xPaw opened this issue · 1 comments

xPaw commented

if (data.Count < 12) { header = default; return false; }
header = System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, Ktx2Header>(data.ToArray())[0];

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.

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...