Skip to content

Commit 11c8e19

Browse files
authored
Merge pull request #198 from Ghabry/development
Fix #194 (heap corruption) and #196 (LcfWriter writing incorrect strings)
2 parents d1d1c41 + 98c8709 commit 11c8e19

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/ldb_eventcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void RawStruct<RPG::EventCommand>::WriteLcf(const RPG::EventCommand& event_comma
4545
stream.Write(event_command.code);
4646
stream.Write(event_command.indent);
4747
stream.WriteInt(stream.Decode(event_command.string).size());
48-
stream.Write(event_command.string);
48+
stream.Write(stream.Decode(event_command.string));
4949
int count = event_command.parameters.size();
5050
stream.Write(count);
5151
for (int i = 0; i < count; i++)

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)