Compare commits

..

21 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
c4e4155bf7 Super final review: fix cj_unescape_string data-loss, escape-scan infinite loop, operator[] destructor
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-18 21:44:18 +00:00
copilot-swe-agent[bot]
5dfa17d14b Final review: fix stray *out_len=len UB, add get<T> primary template for size_t
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-18 20:16:01 +00:00
Syoyo Fujita
5b87beb373 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:39:27 +09:00
Syoyo Fujita
0ab7e74933 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:39:13 +09:00
Syoyo Fujita
247cb388a0 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:38:55 +09:00
Syoyo Fujita
eb087e80e7 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:38:40 +09:00
Syoyo Fujita
690585fa73 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:38:28 +09:00
Syoyo Fujita
73d309ebfa Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:38:10 +09:00
Syoyo Fujita
4d16d528a5 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:37:50 +09:00
Syoyo Fujita
229f2b8c88 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:37:37 +09:00
Syoyo Fujita
ad531900cb Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 02:37:10 +09:00
copilot-swe-agent[bot]
9da2046cba Mitochondria-level review: fix NULL ptr + nonzero length → serializer overread (6 sites)
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-18 04:34:13 +00:00
copilot-swe-agent[bot]
ed13b0422a Deepest-ever review: NaN/Inf->null, operator[] null key, copy_from_ arr_size_ tracking
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-18 04:10:06 +00:00
copilot-swe-agent[bot]
1dfcb11442 Ultra deep final review: 6 correctness/safety fixes in tinygltf_json.h
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-18 03:32:36 +00:00
copilot-swe-agent[bot]
a2b55f008e Fix security/correctness issues from thorough code review of tinygltf_json.h
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 23:17:24 +00:00
copilot-swe-agent[bot]
fdf528f9aa Make C++ exceptions optional in tinygltf_json.h (default off)
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 19:33:02 +00:00
copilot-swe-agent[bot]
ebcd8cc4ee Replace recursive parser with iterative loop using CJ_MAX_ITER explicit frame stack
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 19:24:38 +00:00
copilot-swe-agent[bot]
f6c71cf88b Security fixes: null key guard, allocation overflow protection, parser depth limit
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 16:02:25 +00:00
copilot-swe-agent[bot]
5aaa3e4daf Remove accidental test artifact files and update .gitignore
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 15:52:12 +00:00
copilot-swe-agent[bot]
1117aa7191 Add tinygltf_json.h: fast custom JSON parser with optional SIMD support
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
2026-03-17 15:49:46 +00:00
copilot-swe-agent[bot]
bdba4dfb4c Initial plan 2026-03-17 15:15:01 +00:00
4 changed files with 1956 additions and 17 deletions

13
.gitignore vendored
View File

@@ -70,6 +70,19 @@ tests/tester
tests/tester_noexcept
tests/issue-97.gltf
tests/issue-261.gltf
tests/issue-495-external.gltf
# Test-generated output files (written by tester.cc during test run)
tests/Cube.gltf
tests/Cube.bin
tests/Cube.glb
tests/Cube_BaseColor.png
tests/Cube_MetallicRoughness.png
tests/Cube_with_embedded_images.gltf
tests/Cube_with_image_files.gltf
tests/tmp.glb
tests/ issue-236.gltf
tests/ issue-236.bin
tests/ 2x2 image has multiple spaces.png
# unignore
!Makefile

View File

@@ -18,6 +18,7 @@ option(TINYGLTF_BUILD_TESTS "Build unit tests" OFF)
option(TINYGLTF_HEADER_ONLY "On: header-only mode. Off: create tinygltf library(No TINYGLTF_IMPLEMENTATION required in your project)" OFF)
option(TINYGLTF_INSTALL "Install tinygltf files during install step. Usually set to OFF if you include tinygltf through add_subdirectory()" ON)
option(TINYGLTF_INSTALL_VENDOR "Install vendored nlohmann/json and nothings/stb headers" ON)
option(TINYGLTF_USE_CUSTOM_JSON "Use the built-in fast JSON parser (tinygltf_json.h) instead of nlohmann/json" OFF)
if (TINYGLTF_BUILD_LOADER_EXAMPLE)
add_executable(loader_example
@@ -46,6 +47,15 @@ if (TINYGLTF_BUILD_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/tests
)
add_test(NAME tester COMMAND tester WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
# Build and run tests with the custom JSON backend enabled to catch regressions
add_executable(tester_customjson tests/tester.cc)
target_include_directories(tester_customjson PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tests
)
target_compile_definitions(tester_customjson PRIVATE TINYGLTF_USE_CUSTOM_JSON)
add_test(NAME tester_customjson COMMAND tester_customjson WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif (TINYGLTF_BUILD_TESTS)
#
@@ -71,6 +81,14 @@ else (TINYGLTF_HEADER_ONLY)
)
endif (TINYGLTF_HEADER_ONLY)
if (TINYGLTF_USE_CUSTOM_JSON)
if (TINYGLTF_HEADER_ONLY)
target_compile_definitions(tinygltf INTERFACE TINYGLTF_USE_CUSTOM_JSON)
else ()
target_compile_definitions(tinygltf PUBLIC TINYGLTF_USE_CUSTOM_JSON)
endif ()
endif ()
if (TINYGLTF_INSTALL)
install(TARGETS tinygltf EXPORT tinygltfTargets)
install(EXPORT tinygltfTargets NAMESPACE tinygltf:: FILE TinyGLTFTargets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/tinygltf)
@@ -80,6 +98,7 @@ if (TINYGLTF_INSTALL)
INSTALL ( FILES
tiny_gltf.h
tinygltf_json.h
${TINYGLTF_EXTRA_SOUECES}
DESTINATION
include

View File

@@ -25,21 +25,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Version:
// - v2.9.0 Filesystem API has been changed.
// - v2.8.0 Add URICallbacks for custom URI handling in Buffer and Image.
// - v2.7.0 Change WriteImageDataFunction user callback function signature.
// - v2.6.0 Support serializing sparse accessor(Thanks to @fynv).
// Disable expanding file path for security(no use of awkward `wordexp` anymore).
// - v2.5.0 Add SetPreserveImageChannels() option to load image data as is.
// - v2.4.0 Experimental RapidJSON and C++14 support(Thanks to @jrkoone).
// - v2.3.0 Modified Material representation according to glTF 2.0 schema
// (and introduced TextureInfo class).
// - v2.2.0 Add loading 16bit PNG support. Add Sparse accessor support(Thanks to @Ybalrid)
// - v2.1.0 Add draco compression.
// - v2.0.0 glTF 2.0!
//
// See https://github.com/syoyo/tinygltf/releases for full release history.
// Version: - v2.9.*
// See https://github.com/syoyo/tinygltf/releases for release history.
//
// Tiny glTF loader is using following third party libraries:
//
@@ -1724,7 +1711,11 @@ class TinyGLTF {
#endif // __GNUC__
#ifndef TINYGLTF_NO_INCLUDE_JSON
#ifndef TINYGLTF_USE_RAPIDJSON
#ifdef TINYGLTF_USE_CUSTOM_JSON
#ifndef TINYGLTF_NO_INCLUDE_CUSTOM_JSON
#include "tinygltf_json.h"
#endif
#elif !defined(TINYGLTF_USE_RAPIDJSON)
#include "json.hpp"
#else
#ifndef TINYGLTF_NO_INCLUDE_RAPIDJSON
@@ -1812,7 +1803,10 @@ class TinyGLTF {
namespace tinygltf {
namespace detail {
#ifdef TINYGLTF_USE_RAPIDJSON
#ifdef TINYGLTF_USE_CUSTOM_JSON
// Types and JsonParse are provided by tinygltf_json.h (already included above)
// via 'namespace tinygltf { namespace detail { ... } }' declarations.
#elif defined(TINYGLTF_USE_RAPIDJSON)
#ifdef TINYGLTF_USE_RAPIDJSON_CRTALLOCATOR
// This uses the RapidJSON CRTAllocator. It is thread safe and multiple
@@ -1884,6 +1878,7 @@ using json_const_array_iterator = json_const_iterator;
using JsonDocument = json;
#endif
#ifndef TINYGLTF_USE_CUSTOM_JSON
void JsonParse(JsonDocument &doc, const char *str, size_t length,
bool throwExc = false) {
#ifdef TINYGLTF_USE_RAPIDJSON
@@ -1893,6 +1888,7 @@ void JsonParse(JsonDocument &doc, const char *str, size_t length,
doc = detail::json::parse(str, str + length, nullptr, throwExc);
#endif
}
#endif // !TINYGLTF_USE_CUSTOM_JSON
} // namespace detail
} // namespace tinygltf
@@ -3449,6 +3445,7 @@ bool DecodeDataURI(std::vector<unsigned char> *out, std::string &mime_type,
return true;
}
#ifndef TINYGLTF_USE_CUSTOM_JSON
namespace detail {
bool GetInt(const detail::json &o, int &val) {
#ifdef TINYGLTF_USE_RAPIDJSON
@@ -3672,6 +3669,7 @@ std::string JsonToString(const detail::json &o, int spacing = -1) {
}
} // namespace detail
#endif // !TINYGLTF_USE_CUSTOM_JSON
static bool ParseJsonAsValue(Value *ret, const detail::json &o) {
Value val{};
@@ -6975,6 +6973,7 @@ bool TinyGLTF::LoadBinaryFromFile(Model *model, std::string *err,
///////////////////////
// GLTF Serialization
///////////////////////
#ifndef TINYGLTF_USE_CUSTOM_JSON
namespace detail {
detail::json JsonFromString(const char *s) {
#ifdef TINYGLTF_USE_RAPIDJSON
@@ -7047,6 +7046,7 @@ void JsonReserveArray(detail::json &o, size_t s) {
(void)(s);
}
} // namespace detail
#endif // !TINYGLTF_USE_CUSTOM_JSON
// typedef std::pair<std::string, detail::json> json_object_pair;

1907
tinygltf_json.h Normal file

File diff suppressed because it is too large Load Diff