Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7712f1b

Browse files
authored
Fix crash when reading mtllib command
The code was assuming the mtllib command to be near the beginning of the file, and therefore to always be read by the first thread.
1 parent 6f990e2 commit 7712f1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

experimental/tinyobj_loader_opt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,9 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
14141414
}
14151415

14161416
if (command.type == COMMAND_MTLLIB) {
1417+
// Save the indices of the `mtllib` command in `commands` to easily find it later
14171418
mtllib_t_index = t;
1418-
mtllib_i_index = commands->size();
1419+
mtllib_i_index = commands[t].size();
14191420
}
14201421

14211422
commands[t].emplace_back(std::move(command));

0 commit comments

Comments
 (0)