From c1254caf25cc12281318402ec71a89ff8fe0d591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Tue, 25 Oct 2016 15:38:32 +0200 Subject: [PATCH] fixed a bug, where Char::operator= made the allocated data larger than needed --- Char.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Char.cpp b/Char.cpp index ec18d74..7718b12 100644 --- a/Char.cpp +++ b/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; -} \ No newline at end of file +}