From f985381049f945a391fd8dd2dc4c60191799d217 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:34:21 +0000 Subject: [PATCH 1/2] Initial plan From c55665b60c6ff0636931ded6cc042d88010c8c60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:39:43 +0000 Subject: [PATCH 2/2] Fix tg3_writer allocation: use new/delete instead of calloc/free Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com> Agent-Logs-Url: https://github.com/syoyo/tinygltf/sessions/c2a9ce6c-1c60-4925-b67b-e5ad2ffe1cd2 --- tiny_gltf_v3.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tiny_gltf_v3.h b/tiny_gltf_v3.h index 1d100a4..3cb131f 100644 --- a/tiny_gltf_v3.h +++ b/tiny_gltf_v3.h @@ -4309,7 +4309,7 @@ struct tg3_writer { TINYGLTF3_API tg3_writer *tg3_writer_create( tg3_write_chunk_fn chunk_fn, void *user_data, const tg3_write_options *options) { - tg3_writer *w = (tg3_writer *)calloc(1, sizeof(tg3_writer)); + tg3_writer *w = new (std::nothrow) tg3_writer(); if (!w) return NULL; w->chunk_fn = chunk_fn; w->user_data = user_data; @@ -4385,10 +4385,7 @@ TINYGLTF3_API tg3_error_code tg3_writer_end(tg3_writer *w) { } TINYGLTF3_API void tg3_writer_destroy(tg3_writer *w) { - if (w) { - w->root.~tinygltf_json(); - free(w); - } + delete w; } #endif /* TINYGLTF3_IMPLEMENTATION */