From 7712f1bebdc898e8cf82a00d0af7524aedf160df Mon Sep 17 00:00:00 2001 From: Neptilo Date: Fri, 4 Jan 2019 13:57:34 +0100 Subject: [PATCH] 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. --- experimental/tinyobj_loader_opt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/experimental/tinyobj_loader_opt.h b/experimental/tinyobj_loader_opt.h index 8e57cf1..d2b007d 100644 --- a/experimental/tinyobj_loader_opt.h +++ b/experimental/tinyobj_loader_opt.h @@ -1414,8 +1414,9 @@ bool parseObj(attrib_t *attrib, std::vector *shapes, } if (command.type == COMMAND_MTLLIB) { + // Save the indices of the `mtllib` command in `commands` to easily find it later mtllib_t_index = t; - mtllib_i_index = commands->size(); + mtllib_i_index = commands[t].size(); } commands[t].emplace_back(std::move(command));