Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Syoyo Fujita
2026-03-19 02:38:28 +09:00
committed by GitHub
co-authored by Copilot Autofix powered by AI
parent 7c7eadba3a
commit d910e58c3a
+7 -3
View File
@@ -1077,10 +1077,14 @@ inline tinygltf_json &tinygltf_json::operator[](const char *key) {
new (nm) tinygltf_json_member();
size_t klen = strlen(key);
nm->key = (char *)malloc(klen + 1);
if (nm->key) {
memcpy(nm->key, key, klen + 1);
nm->key_len = klen;
if (!nm->key) {
/* Roll back insertion on key allocation failure: do not bump
* obj_size_, and return the shared null fallback, keeping the
* object in a consistent state. */
return null_fallback;
}
memcpy(nm->key, key, klen + 1);
nm->key_len = klen;
++obj_size_;
return nm->val;
}