jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.42k stars 135 forks source link

Ensure that for builtin types, attribute index is non-negative #236

Closed zeux closed 8 months ago

zeux commented 9 months ago

glTF specification guarantees that the indices of builtin attributes are natural numbers; atoi can return a negative number, which is likely to cause problems for client code (for example, even if it attempts to range-check the texture coordinate index before writing it to internal mesh representation, index < 8 will not work because index can be negative).

zeux commented 9 months ago

(I think this is going to be the last validation PR for a few months; there are still some alignment issues visible under UBSAN left but they aren't super critical to fix)