From 2e6987967e9cbea933619c4a5f78b226acb49c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=97=84=ED=83=9C=EC=9A=A9?= Date: Mon, 30 Jun 2025 07:27:24 +0900 Subject: [PATCH] Use jv_mem_alloc to allocate dtoa_context in tsd_dtoa_context_get (#3356) --- src/jv_dtoa_tsd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jv_dtoa_tsd.c b/src/jv_dtoa_tsd.c index c321f3db..3f45e974 100644 --- a/src/jv_dtoa_tsd.c +++ b/src/jv_dtoa_tsd.c @@ -40,9 +40,10 @@ inline struct dtoa_context *tsd_dtoa_context_get(void) { pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key); if (!ctx) { - ctx = malloc(sizeof(struct dtoa_context)); + ctx = jv_mem_alloc(sizeof(struct dtoa_context)); jvp_dtoa_context_init(ctx); if (pthread_setspecific(dtoa_ctx_key, ctx) != 0) { + jv_mem_free(ctx); fprintf(stderr, "error: cannot set thread specific data"); abort(); }