mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-10-31 21:15:42 +00:00
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:
committed by
GitHub
co-authored by
Copilot Autofix powered by AI
parent
7c7eadba3a
commit
d910e58c3a
+7
-3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user