Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

obj-parsing fails if a comment is at the end of a line of a definition with variable number of elements to read. #389

Copy link
Copy link
@scschaefer

Description

@scschaefer
Issue body actions

Describe the issue
The parser fails and stops parsing if a comment is at the end of a line defining an element with a variable number of possible elements following the token. For example, when defining a line like l 1 3 # First line, it's unknown how many vertex indices follow after the l. The while loop condition only looks for new line characters. Subsequently, the parser fails when it encounters the # character.

To Reproduce
Steps to reproduce the behaviour:

  1. Compile TinyObjLoader
  2. Load the .obj-file in the attached .zip-archive via ParseFromFile: linien.zip
  3. See error: Failed to parse `l' line (e.g. a zero value for vertex index. Line 43).

For convenience, try this example project:
tiny_obj_loader_parser_bug.zip

Remarks
This bug only applies to tokens that have a variable number of elements:

  • vw (skin weight)
  • l (line)
  • p (points)
  • f (face)
  • g (group)

Expected behaviour
The parser should stop parsing a line once it reaches the comment character #.

Environment

  • TinyObjLoader version: The latest version of tiny_obj_loader.h (commit 5cd3842)
  • OS: Windows 10 x64
  • Compiler: MSVC 17.10.9 with C++20 support enabled
  • Other environment: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.