From 2b8cd25499f3f16daaffc595ed28366129fe6307 Mon Sep 17 00:00:00 2001 From: IgorCielniak Date: Thu, 25 Dec 2025 10:59:21 +0100 Subject: [PATCH] unhardcoded alloc size in strconcat so the buffer doesn't overflow --- stdlib/stdlib.sl | 7 +++++++ strconcat.sl | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/stdlib/stdlib.sl b/stdlib/stdlib.sl index 1444064..aea5c84 100644 --- a/stdlib/stdlib.sl +++ b/stdlib/stdlib.sl @@ -1,3 +1,10 @@ +: debug + for + puti cr + next + exit +; + # : int3 ( -- ) :asm int3 { int3 diff --git a/strconcat.sl b/strconcat.sl index ab7503a..b0d0c9b 100644 --- a/strconcat.sl +++ b/strconcat.sl @@ -3,8 +3,10 @@ import stdlib/io.sl : strconcat 0 pick 3 pick + - >r >r >r >r >r - 8 alloc + dup + >r >r >r >r >r >r + 5 rpick + alloc r> r> dup >r strcpy @@ -20,6 +22,9 @@ import stdlib/io.sl swap 0 rpick nip + rot + drop + rdrop rdrop rdrop ; : alloc @@ -64,7 +69,7 @@ import stdlib/io.sl ; : main - "hello " "world" + "hello world hello world hello " "world hello world hello world" strconcat puts ; \ No newline at end of file