mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-07-04 04:35:13 +08:00
Fix possible out of bounds index in LoadFromString
This commit is contained in:
parent
4581d37bec
commit
e413216722
27
tiny_gltf.h
27
tiny_gltf.h
@ -5803,20 +5803,27 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto &attribute : primitive.attributes) {
|
for (auto &attribute : primitive.attributes) {
|
||||||
model
|
const auto accessorsIndex = size_t(attribute.second);
|
||||||
->bufferViews[size_t(
|
if (accessorsIndex < model->accessors.size()) {
|
||||||
model->accessors[size_t(attribute.second)].bufferView)]
|
const auto bufferView = model->accessors[accessorsIndex].bufferView;
|
||||||
.target = TINYGLTF_TARGET_ARRAY_BUFFER;
|
// bufferView could be null(-1) for sparse morph target
|
||||||
|
if (bufferView >= 0 && bufferView < model->bufferViews.size()) {
|
||||||
|
model->bufferViews[size_t(bufferView)].target =
|
||||||
|
TINYGLTF_TARGET_ARRAY_BUFFER;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &target : primitive.targets) {
|
for (auto &target : primitive.targets) {
|
||||||
for (auto &attribute : target) {
|
for (auto &attribute : target) {
|
||||||
auto bufferView =
|
const auto accessorsIndex = size_t(attribute.second);
|
||||||
model->accessors[size_t(attribute.second)].bufferView;
|
if (accessorsIndex < model->accessors.size()) {
|
||||||
// bufferView could be null(-1) for sparse morph target
|
const auto bufferView = model->accessors[accessorsIndex].bufferView;
|
||||||
if (bufferView >= 0) {
|
// bufferView could be null(-1) for sparse morph target
|
||||||
model->bufferViews[size_t(bufferView)].target =
|
if (bufferView >= 0 && bufferView < model->bufferViews.size()) {
|
||||||
TINYGLTF_TARGET_ARRAY_BUFFER;
|
model->bufferViews[size_t(bufferView)].target =
|
||||||
|
TINYGLTF_TARGET_ARRAY_BUFFER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user