From a8843fa5a8f2c71407923628fce141d62b8774b6 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 5 Nov 2019 22:33:14 +0300 Subject: [PATCH] Make sure MultiChar::data() constructs a valid string mData may ultimately not be a valid C-string (e.g. if it contains 4 significant characters) so it may not necessarily be converted into a valid std::string --- components/compiler/scanner.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index c8a528348..b8d057677 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -165,7 +165,8 @@ namespace Compiler std::string data() { - return mData; + // NB: mLength is the number of the last element in the array + return std::string(mData, mLength + 1); } private: