From 4dc3d8f8325994d737f1959c1554480f4ccbc60f Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 30 May 2025 08:12:49 +0100 Subject: Fix issue with memory allocations in lisp::serialise Was to do with sv_make. --- lisp/lisp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/lisp.c b/lisp/lisp.c index 24a4788..e1524a4 100644 --- a/lisp/lisp.c +++ b/lisp/lisp.c @@ -252,7 +252,13 @@ sv_t serialise(context_t *ctx, lisp_t *ptr) lmember = CAR(lmember); sv_t member = serialise(ctx, lmember); - s = sv_concat(&ctx->scratch, s, member); + if (!s.data) + s = member; + else + s = sv_concat(&ctx->scratch, s, member); + + // NOTE: eventually this separator we add per item should be mutable at + // runtime. if (IS_TAG(lsp, CONS) && !CDR(lsp)) continue; else if (IS_TAG(CDR(lsp), CONS)) -- cgit v1.2.3-13-gbd6f