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(); }