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

panic: index out of range #18

Open
xackery opened this issue Jul 8, 2022 · 4 comments
Open

panic: index out of range #18

xackery opened this issue Jul 8, 2022 · 4 comments

Comments

@xackery
Copy link

xackery commented Jul 8, 2022


goroutine 1 [running, locked to thread]:
github.com/solarlune/tetra3d.LoadGLTFData({0xc00044c000, 0x1d81b, 0x1d81b}, 0x0)
        /Users/xackery/Documents/code/go/pkg/mod/github.com/solarlune/[email protected]/gltf.go:162 +0x8e7a
exit status 2

seems:

newMat.TexturePath = doc.Images[*doc.Textures[texture.Index].Source].URI

is missing sanity checks and making assumptions, I'm using something similar to https://github.com/qmuntal/gltf/blob/80d3922a76d3e24371f8c99e0d213ecc8dae3ffe/modeler/example_test.go#L35 to generate a gltf and it is cutting corners on some steps, and causing tetra3d to panic non-gracefully

@xackery
Copy link
Author

xackery commented Jul 8, 2022

A fix could be something like:

if int(texture.Index) > len(doc.Images) {
				return nil, fmt.Errorf("texture index %d is beyond length of images (%d)", texture.Index, len(doc.Images))
			}

@SolarLune
Copy link
Owner

SolarLune commented Jul 9, 2022

Hello! I'm not certain I understand - are you generating a GLTF file and setting the texture's index to be a value that doesn't exist?

@khaelou
Copy link

khaelou commented Feb 4, 2023

@xackery

@xackery
Copy link
Author

xackery commented Feb 4, 2023

Hi @SolarLune and @khaelou,
Yes,
I am a converting from a propietary format to a GLTF, and not every the texture's index is properly referred to in doc.Images array, and I'll have to manually sanity check this or recover from panics with the current design.

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

No branches or pull requests

3 participants