Fixed writing past end of the buffer when loading personal item tracker notes longer than 8 characters

This commit is contained in:
Evgenii Babinets 2023-02-20 13:56:26 -05:00
parent 4a8e6dcfea
commit 721c18d488

View File

@ -1102,6 +1102,7 @@ void InitItemTracker() {
}); });
Ship::RegisterHook<Ship::LoadFile>([](uint32_t fileNum) { Ship::RegisterHook<Ship::LoadFile>([](uint32_t fileNum) {
const char* initialTrackerNotes = CVarGetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); const char* initialTrackerNotes = CVarGetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), "");
itemTrackerNotes.resize(strlen(initialTrackerNotes) + 1);
strcpy(itemTrackerNotes.Data, initialTrackerNotes); strcpy(itemTrackerNotes.Data, initialTrackerNotes);
}); });
Ship::RegisterHook<Ship::DeleteFile>([](uint32_t fileNum) { Ship::RegisterHook<Ship::DeleteFile>([](uint32_t fileNum) {