From d17ceb3c53844a8393b4c429e85ba80fb2743ea7 Mon Sep 17 00:00:00 2001 From: kakadu Date: Mon, 10 Oct 2022 18:31:27 +0300 Subject: [PATCH] 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 --- runtime/runtime.c | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/runtime.c b/runtime/runtime.c index a2f15d05f..6710bd94a 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -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; }