aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-05-30 08:12:49 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-05-30 08:12:49 +0100
commit4dc3d8f8325994d737f1959c1554480f4ccbc60f (patch)
tree0636c4fc330b6772e5ea12defa7d6f5d108f11e0 /lisp
parentbfff660d0e1a03063b889f84e8cfd046565c6046 (diff)
downloadoats-4dc3d8f8325994d737f1959c1554480f4ccbc60f.tar.gz
oats-4dc3d8f8325994d737f1959c1554480f4ccbc60f.tar.bz2
oats-4dc3d8f8325994d737f1959c1554480f4ccbc60f.zip
Fix issue with memory allocations in lisp::serialise
Was to do with sv_make.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/lisp.c8
1 files changed, 7 insertions, 1 deletions
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))