From 0949983acccdece1c76e6d30585a4503c9cad6e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 21:15:45 +0000 Subject: [PATCH 1/2] Initial plan From 5e0c5b9ada589a72c2153b49e61348d1ef548e23 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 21:21:35 +0000 Subject: [PATCH 2/2] Fix tg3__arena_strdup to distinguish empty strings from absent strings Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com> Agent-Logs-Url: https://github.com/syoyo/tinygltf/sessions/445ab61b-4294-45e6-8faf-4f2fc8dfe369 --- tiny_gltf_v3.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tiny_gltf_v3.h b/tiny_gltf_v3.h index 931af22..01a58f0 100644 --- a/tiny_gltf_v3.h +++ b/tiny_gltf_v3.h @@ -1358,10 +1358,13 @@ static void *tg3__arena_alloc(tg3_arena *arena, size_t size) { } static char *tg3__arena_strdup(tg3_arena *arena, const char *s, size_t len) { - if (!s || len == 0) return NULL; + if (!s) return NULL; + /* Allocate len+1 bytes; when len==0 this produces a 1-byte "\0" buffer so + * that empty strings (data!=NULL, len==0) remain distinguishable from + * absent strings (data==NULL, len==0). */ char *dst = (char *)tg3__arena_alloc(arena, len + 1); if (!dst) return NULL; - memcpy(dst, s, len); + if (len > 0) memcpy(dst, s, len); dst[len] = '\0'; return dst; }