Fix missing nil terminators in strings read by marshal reader

This commit is contained in:
K. Lange 2021-02-12 15:57:54 +09:00
parent e6a50d6746
commit 7d18c9fb1a

View File

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