Skip to content

GLTF: Incorrect useage of InputStream.skipBytes() #2555

@ScottPeterJohnson

Description

@ScottPeterJohnson

The method contract of InputStream.skipBytes() is:
Makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes. However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. This method never throws an EOFException. The actual number of bytes skipped is returned.

This is nearly always not what you want and is a bountiful source of bugs. At a glance these locations in the code all use this method:




leIn.skipBytes(8); // internal struct length (always 36)

The one that impacted me was the GLTF loader, causing it to break on some asset imports.

I think this would be fixed for the GLTF loader with:
l/2553

All other places should probably use a helper utility that will skip exactly as many bytes as requested.

Metadata

Metadata

Assignees

Labels

bugSomething that is supposed to work, but doesn't. More severe than a "defect".

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions