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

Validate that material variant names aren't NULL #235

Closed zeux closed 8 months ago

zeux commented 9 months ago

Some names in glTF data structures are required and some are optional.

We normally ensure that names that are required can't be NULL as a byproduct of how they are parsed: required names usually come up when they are JSON object keys, so a lack of a name means the object isn't parsed.

Material variants are an odd exception: the name is required (in fact it's the only thing that a variant has...), but it's stored as a "name" key in an array of objects because the extension needs to maintain variant order. It's natural for the user to assume that the name is not NULL as the spec requires that, but it can be NULL in non-compliant documents, so we validate this now.