From bc2255de6b2ce0b8d19e49d6d1a29004f44d6e9f Mon Sep 17 00:00:00 2001 From: Shwoomple <> Date: Sat, 12 Nov 2022 11:51:43 +0530 Subject: [PATCH] lib/file: Fix issue #71 - Electric Boogaloo (Out of bounds access) Add size constraint to make sure string terminates at the correct length. Cygwin appears to not put null bytes to terminate string when reading from a file stream. --- src/lib/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/file.cpp b/src/lib/file.cpp index bfdd245..15a0b45 100644 --- a/src/lib/file.cpp +++ b/src/lib/file.cpp @@ -225,7 +225,7 @@ ErrorOrVoid File::insertString(tiny_utf8::string string){ this->fileStream.read(reinterpret_cast(buffer), this->size.value); - readData = tiny_utf8::string((char *) buffer); + readData = tiny_utf8::string((char *) buffer, 0, this->size.value); readData.insert(readData.begin()+this->cursorPosition, string); this->fileStream.seekg(0);