From 55ac3dca70e50369b6f6fd686b8be47bf4f93a4a Mon Sep 17 00:00:00 2001 From: Ben Payne Date: Tue, 10 Feb 2015 23:53:15 -0500 Subject: [PATCH] Fix assignment operator --- Engine/source/core/strings/unicode.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Engine/source/core/strings/unicode.cpp b/Engine/source/core/strings/unicode.cpp index 4496da76b..64acee244 100644 --- a/Engine/source/core/strings/unicode.cpp +++ b/Engine/source/core/strings/unicode.cpp @@ -103,13 +103,17 @@ struct UTF16Cache dMemcpy(mString, other.mString, mLength * sizeof(UTF16)); } - void operator =(const UTF16Cache &other) + UTF16Cache & operator =(const UTF16Cache &other) { - delete [] mString; + if (&other != this) + { + delete [] mString; - mLength = other.mLength; - mString = new UTF16[mLength]; - dMemcpy(mString, other.mString, mLength * sizeof(UTF16)); + mLength = other.mLength; + mString = new UTF16[mLength]; + dMemcpy(mString, other.mString, mLength * sizeof(UTF16)); + } + return *this; } ~UTF16Cache()