Skip to content

Commit

Permalink
Ensure that for builtin types, attribute index is non-negative
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
zeux committed Oct 28, 2023
1 parent fd3a618 commit f583f40
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cgltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,11 @@ static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* o
if (us && *out_type != cgltf_attribute_type_invalid)
{
*out_index = CGLTF_ATOI(us + 1);
if (*out_index < 0)
{
*out_type = cgltf_attribute_type_invalid;
*out_index = 0;
}
}
}

Expand Down

0 comments on commit f583f40

Please sign in to comment.