Skip to content

Commit 98c8709

Browse files
committed
Fix an integer overflow in LcfReader::ReadString resulting in a heap corruption.
Thanks to @Scrippie Fixes #194
1 parent 5abb593 commit 98c8709

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/reader_lcf.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ void LcfReader::Read<uint32_t>(std::vector<uint32_t> &buffer, size_t size) {
160160
}
161161

162162
void LcfReader::ReadString(std::string& ref, size_t size) {
163-
char* chars = new char[size + 1];
164-
chars[size] = '\0';
163+
char* chars = new char[size];
165164
Read(chars, 1, size);
166-
ref = Encode(std::string(chars));
165+
ref = Encode(std::string(chars, size));
167166
delete[] chars;
168167
}
169168

0 commit comments

Comments
 (0)