diff --git a/source/code/sago/SagoTextField.cpp b/source/code/sago/SagoTextField.cpp index a6c795b..7add13a 100644 --- a/source/code/sago/SagoTextField.cpp +++ b/source/code/sago/SagoTextField.cpp @@ -84,13 +84,19 @@ SagoTextField::SagoTextField(SagoTextField&& o) noexcept { } SagoTextField& SagoTextField::operator=(const SagoTextField& base) { - data = base.data; - //Copy all data but do not reuse the cache as it would result in a double free - data->outlineTextSurface = nullptr; - data->outlineTexture = nullptr; - data->textSurface = nullptr; - data->texture = nullptr; - return *this; + data = new SagoTextFieldData(); + try { + *data = *(base.data); + //Copy all data but do not reuse the cache as it would result in a double free + data->outlineTextSurface = nullptr; + data->outlineTexture = nullptr; + data->textSurface = nullptr; + data->texture = nullptr; + return *this; + } catch (...) { + delete data; + throw; + } } SagoTextField::~SagoTextField() {