unhardcoded alloc size in strconcat so the buffer doesn't overflow
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
: debug
|
||||||
|
for
|
||||||
|
puti cr
|
||||||
|
next
|
||||||
|
exit
|
||||||
|
;
|
||||||
|
|
||||||
# : int3 ( -- )
|
# : int3 ( -- )
|
||||||
:asm int3 {
|
:asm int3 {
|
||||||
int3
|
int3
|
||||||
|
|||||||
11
strconcat.sl
11
strconcat.sl
@@ -3,8 +3,10 @@ import stdlib/io.sl
|
|||||||
|
|
||||||
: strconcat
|
: strconcat
|
||||||
0 pick 3 pick +
|
0 pick 3 pick +
|
||||||
>r >r >r >r >r
|
dup
|
||||||
8 alloc
|
>r >r >r >r >r >r
|
||||||
|
5 rpick
|
||||||
|
alloc
|
||||||
r> r>
|
r> r>
|
||||||
dup >r
|
dup >r
|
||||||
strcpy
|
strcpy
|
||||||
@@ -20,6 +22,9 @@ import stdlib/io.sl
|
|||||||
swap
|
swap
|
||||||
0 rpick
|
0 rpick
|
||||||
nip
|
nip
|
||||||
|
rot
|
||||||
|
drop
|
||||||
|
rdrop rdrop rdrop
|
||||||
;
|
;
|
||||||
|
|
||||||
: alloc
|
: alloc
|
||||||
@@ -64,7 +69,7 @@ import stdlib/io.sl
|
|||||||
;
|
;
|
||||||
|
|
||||||
: main
|
: main
|
||||||
"hello " "world"
|
"hello world hello world hello " "world hello world hello world"
|
||||||
strconcat
|
strconcat
|
||||||
puts
|
puts
|
||||||
;
|
;
|
||||||
Reference in New Issue
Block a user