Merge pull request #7792 from oystedal/oystedal/string-memleaks

Fix memory leaks related to pointer assignment to std::string
This commit is contained in:
Michał Janiszewski authored and GitHub committed 2018-07-21 19:56:55 +02:00
commit b278dce717
5 files changed
+15 -5

No files matched your search

+1
View File
@@ -112,6 +112,7 @@ The following people are not part of the development team, but have been contrib
* Patrick Martinez (martip23)
* Andy Ford (AndyTWF)
* Matthew Beaudin (mattbeaudin)
* Øystein Dale (oystedal)
## Toolchain
* (Balletie) - macOS
+1 -1
View File
@@ -354,7 +354,7 @@ private:
sb.Append(&c, 1);
}
}
return std::string(sb.GetString());
return sb.GetStdString();
}
std::string GetLine(size_t index)
+9
View File
@@ -10,6 +10,7 @@
#pragma once
#include <algorithm>
#include <string>
#include "../common.h"
#include "Math.hpp"
@@ -132,6 +133,14 @@ public:
return result;
}
/**
* Returns the current string buffer as a standard string.
*/
std::string GetStdString() const
{
return std::string(_buffer, _length);
}
/**
* Gets the current state of the StringBuilder. Warning: this represents the StringBuilder's current working buffer and will
* be deallocated when the StringBuilder is destructed.
+2 -2
View File
@@ -389,7 +389,7 @@ private:
}
if (sb.GetLength() == 8)
{
_currentGroup = sb.GetString();
_currentGroup = sb.GetStdString();
_currentObjectOverride = GetObjectOverride(_currentGroup);
_currentScenarioOverride = nullptr;
if (_currentObjectOverride == nullptr)
@@ -432,7 +432,7 @@ private:
if (closedCorrectly)
{
_currentGroup = sb.GetString();
_currentGroup = sb.GetStdString();
_currentObjectOverride = nullptr;
_currentScenarioOverride = GetScenarioOverride(_currentGroup);
if (_currentScenarioOverride == nullptr)
+2 -2
View File
@@ -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: