Skip to content

Commit

Permalink
Merge pull request #44 from xmusjackson/fix-setexportinfo
Browse files Browse the repository at this point in the history
Limit substring length in NiHeader::SetExportInfo
  • Loading branch information
ousnius authored Aug 4, 2024
2 parents 868b648 + 15099e6 commit 1124519
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/BasicTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ class NiHeader : public NiHeaderBase, public NiCloneable<NiHeader, NiObject> {

std::string GetExportInfo() const;

// Sets export info string (automatically split into three members after 256 characters each)
// Sets export info string (automatically split into three members after 254 characters each)
void SetExportInfo(const std::string& exportInfo);

// Sets pointer to all blocks in the file
Expand Down
6 changes: 3 additions & 3 deletions src/BasicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ void NiHeader::SetExportInfo(const std::string& exportInfo) {
exportStrings[2] = &exportInfo3;

auto it = exportStrings.begin();
for (size_t i = 0; i < exportInfo.length() && it < exportStrings.end(); i += 256, ++it) {
if (i + 256 <= exportInfo.length())
(*it)->get() = exportInfo.substr(i, 256);
for (size_t i = 0; i < exportInfo.length() && it < exportStrings.end(); i += 254, ++it) {
if (i + 254 <= exportInfo.length())
(*it)->get() = exportInfo.substr(i, 254);
else
(*it)->get() = exportInfo.substr(i, exportInfo.length() - i);
}
Expand Down

0 comments on commit 1124519

Please sign in to comment.