From 7d18c9fb1a93356debc99385a3ea90a184225376 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 12 Feb 2021 15:57:54 +0900 Subject: [PATCH] Fix missing nil terminators in strings read by marshal reader --- tools/compile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/compile.c b/tools/compile.c index a6acc51..d2bc663 100644 --- a/tools/compile.c +++ b/tools/compile.c @@ -490,8 +490,9 @@ static int readFile(char * fileName) { uint32_t strLen; assert(fread(&strLen, 1, sizeof(uint32_t), inFile) == sizeof(uint32_t)); - char * strVal = malloc(strLen); + char * strVal = malloc(strLen+1); assert(fread(strVal, 1, strLen, inFile) == strLen); + strVal[strLen] = '\0'; /* Create a string */ krk_push(OBJECT_VAL(krk_takeString(strVal,strLen)));