fixed a bug, where Char::operator= made the allocated data larger than
needed
This commit is contained in:
parent
af27d29d29
commit
c1254caf25
4
Char.cpp
4
Char.cpp
@ -8,7 +8,7 @@ Char::operator char() const
|
||||
|
||||
Char& Char::operator=(char other)
|
||||
{
|
||||
auto data = new char[_string.size() + 2]; // space for new char & null-terminator
|
||||
auto data = new char[_string.size() + 1]; // space for old string & null-terminator
|
||||
std::strcpy(data, _string.c_str());
|
||||
data[_index] = other; // set the desired char
|
||||
|
||||
@ -17,4 +17,4 @@ Char& Char::operator=(char other)
|
||||
_string._str = new StringValue(data); // make a new one
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user