mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 03:23:15 +01:00
Fix memory leak when deserialising objects
Assigning a pointer to std::string appears to only perform a copy and does not transfer ownership of the pointer, thus the allocated memory is will never be freed. Use IStream::ReadStdString instead to return a std::string directly, thus transferring ownership correctly.
This commit is contained in:
@@ -156,8 +156,8 @@ protected:
|
||||
ObjectRepositoryItem item;
|
||||
|
||||
item.ObjectEntry = stream->ReadValue<rct_object_entry>();
|
||||
item.Path = stream->ReadString();
|
||||
item.Name = stream->ReadString();
|
||||
item.Path = stream->ReadStdString();
|
||||
item.Name = stream->ReadStdString();
|
||||
|
||||
switch (object_entry_get_type(&item.ObjectEntry)) {
|
||||
case OBJECT_TYPE_RIDE:
|
||||
|
||||
Reference in New Issue
Block a user