Runtime: Initializate concatenation buffer by zeros

There was a bug about stringcat-ing of empty list,
where it would be filled by garbage. It seems to
happen becase stringBuf.contents are used without
proper check of length of the buffer. We defend from
that my initializing buffer by zeros (end of string)

Signed-off-by: kakadu <kakadu@pm.me>
This commit is contained in:
kakadu 2022-10-10 18:31:27 +03:00
parent 666ca3b580
commit d17ceb3c53

View file

@ -402,6 +402,7 @@ static StringBuf stringBuf;
static void createStringBuf () {
stringBuf.contents = (char*) malloc (STRINGBUF_INIT);
memset(stringBuf.contents, 0, STRINGBUF_INIT);
stringBuf.ptr = 0;
stringBuf.len = STRINGBUF_INIT;
}