Skip to content

Commit

Permalink
Merge pull request #417 from syoyo/filesize-check
Browse files Browse the repository at this point in the history
Fix to #416
  • Loading branch information
syoyo authored Apr 23, 2023
2 parents 5c06b7d + 1a5046e commit 59cc44a
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 19 deletions.
1 change: 1 addition & 0 deletions tests/issue-416.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"images":[{"uri":"%!QAAAQAAA5"}],"asset":{"version":""}}
36 changes: 36 additions & 0 deletions tests/tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,39 @@ TEST_CASE("serialize-image-failure", "[issue-394]") {
REQUIRE(false == result);
REQUIRE(os.str().size() == 0);
}

TEST_CASE("filesize-check", "[issue-416]") {

tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
std::string warn;

ctx.SetMaxExternalFileSize(10); // 10 bytes. will fail to load texture image.

bool ret = ctx.LoadASCIIFromFile(&model, &err, &warn, "../models/Cube/Cube.gltf");
if (!err.empty()) {
std::cerr << err << std::endl;
}

REQUIRE(false == ret);
}

TEST_CASE("load-issue-416-model", "[issue-416]") {

tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
std::string warn;

bool ret = ctx.LoadASCIIFromFile(&model, &err, &warn, "issue-416.gltf");
if (!warn.empty()) {
std::cout << "WARN:" << warn << std::endl;
}
if (!err.empty()) {
std::cerr << "ERR:" << err << std::endl;
}

// external file load fails, but reading glTF itself is ok.
REQUIRE(true == ret);
}
Loading

0 comments on commit 59cc44a

Please sign in to comment.