unhardcoded alloc size in strconcat so the buffer doesn't overflow

This commit is contained in:
IgorCielniak
2025-12-25 10:59:21 +01:00
parent 60ec54e58c
commit 2b8cd25499
2 changed files with 15 additions and 3 deletions

View File

@@ -1,3 +1,10 @@
: debug
for
puti cr
next
exit
;
# : int3 ( -- )
:asm int3 {
int3

View File

@@ -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
;