From 09d4e5666fb3ee6f30cbf2d77e0579f1b875c10e Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 11 Jul 2015 21:22:58 -0700 Subject: [PATCH] Fix plString constructors from getting the wrong size when using a char array on the stack. They were incorrectly using the string literal constructor. --- Sources/Plasma/CoreLib/plString.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index 3304ffac..d018dae3 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -281,6 +281,10 @@ public: template plString(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz - 1); } + // Don't call the string literal constructor for stack arrays + template + plString(char (&literal)[_Sz]) { IConvertFromUtf8(literal, STRLEN_AUTO); } + /** Copy constructor. */ plString(const plString ©) : fUtf8Buffer(copy.fUtf8Buffer) { } @@ -306,6 +310,10 @@ public: template plString &operator=(const char (&literal)[_Sz]) { IConvertFromUtf8(literal, _Sz - 1); return *this; } + // Don't call the string literal operator= for stack arrays + template + plString &operator=(char (&literal)[_Sz]) { IConvertFromUtf8(literal, STRLEN_AUTO); return *this; } + /** Assignment operator. Same as plString(const plString &). */ plString &operator=(const plString ©) { fUtf8Buffer = copy.fUtf8Buffer; return *this; }