mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Fix memory leak in TrackDesignRepository
This commit is contained in:
@@ -35,6 +35,21 @@ utf8 * IStream::ReadString()
|
||||
return resultString;
|
||||
}
|
||||
|
||||
std::string IStream::ReadStdString()
|
||||
{
|
||||
std::vector<utf8> result;
|
||||
|
||||
uint8 ch;
|
||||
while ((ch = ReadValue<uint8>()) != 0)
|
||||
{
|
||||
result.push_back(ch);
|
||||
}
|
||||
result.push_back(0);
|
||||
|
||||
std::string resultString(result.data(), result.data() + result.size());
|
||||
return resultString;
|
||||
}
|
||||
|
||||
void IStream::WriteString(const utf8 * str)
|
||||
{
|
||||
if (str == nullptr)
|
||||
|
||||
@@ -107,6 +107,7 @@ interface IStream
|
||||
}
|
||||
|
||||
utf8 * ReadString();
|
||||
std::string ReadStdString();
|
||||
void WriteString(const utf8 * str);
|
||||
void WriteString(const std::string &string);
|
||||
};
|
||||
|
||||
@@ -284,10 +284,10 @@ private:
|
||||
for (uint32 i = 0; i < header.NumItems; i++)
|
||||
{
|
||||
TrackRepositoryItem item;
|
||||
item.Name = fs.ReadString();
|
||||
item.Path = fs.ReadString();
|
||||
item.Name = fs.ReadStdString();
|
||||
item.Path = fs.ReadStdString();
|
||||
item.RideType = fs.ReadValue<uint8>();
|
||||
item.ObjectEntry = fs.ReadString();
|
||||
item.ObjectEntry = fs.ReadStdString();
|
||||
item.Flags = fs.ReadValue<uint32>();
|
||||
_items.push_back(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user