Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use size_t for byte offsets #449

Merged
merged 2 commits into from
Sep 2, 2023

Conversation

emimvi
Copy link
Contributor

@emimvi emimvi commented Sep 2, 2023

Hi!

I had a glft file with a single large buffer which i then used in many bufferViews/accessors.
This ended up silently creating an invalid file with negative byteOffsets due to a size_t->int cast overflowing in serialization.

This request fixes that serialization bug, and uses size_t for all byte offsets, instead of a mix depending on struct (bufferView, accessor, accessor::Sparse)

@syoyo
Copy link
Owner

syoyo commented Sep 2, 2023

Good catch!

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_accessor_byteoffset

The spec says byteOffset is ">=0", so we can use size_t(uint).
Let me give some time to review the PR

@syoyo syoyo merged commit 3d445cc into syoyo:release Sep 2, 2023
6 checks passed
@syoyo
Copy link
Owner

syoyo commented Sep 2, 2023

Merged! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants