Skip to content

Commit

Permalink
Fix possible nullptr dereferencing.
Browse files Browse the repository at this point in the history
Add missing `return false`
  • Loading branch information
syoyo committed Dec 4, 2023
1 parent d32f1fb commit 8387fdb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -6149,7 +6149,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
model->accessors[size_t(primitive.indices)].bufferView;
if (bufferView < 0) {
// skip, bufferView could be null(-1) for certain extensions
} else if (size_t(bufferView) >= model->bufferViews.size()) {
} else if (size_t(bufferView) >= model->bufferViews.size()) {
if (err) {
(*err) += "accessor[" + std::to_string(primitive.indices) +
"] invalid bufferView";
Expand Down Expand Up @@ -6671,7 +6671,10 @@ bool TinyGLTF::LoadBinaryFromMemory(Model *model, std::string *err,

if (header_and_json_size > std::numeric_limits<uint32_t>::max()) {
// Do not allow 4GB or more GLB data.
(*err) = "Invalid glTF binary. GLB data exceeds 4GB.";
if (err) {
(*err) = "Invalid glTF binary. GLB data exceeds 4GB.";
}
return false;
}

if ((header_and_json_size > uint64_t(size)) || (chunk0_length < 1) ||
Expand All @@ -6690,6 +6693,7 @@ bool TinyGLTF::LoadBinaryFromMemory(Model *model, std::string *err,
if (err) {
(*err) = "JSON Chunk end does not aligned to a 4-byte boundary.";
}
return false;
}

// std::cout << "header_and_json_size = " << header_and_json_size << "\n";
Expand Down

0 comments on commit 8387fdb

Please sign in to comment.