diff --git a/rtl/eclrtl/eclregex.cpp b/rtl/eclrtl/eclregex.cpp index 0ba83b59123..eaf229f2007 100644 --- a/rtl/eclrtl/eclregex.cpp +++ b/rtl/eclrtl/eclregex.cpp @@ -110,7 +110,7 @@ static void failWithUPCRE2Error(int errCode, const char * msgPrefix, const UChar char * regexStr = nullptr; unsigned regexStrLen; rtlUnicodeToEscapedStrX(regexStrLen, regexStr, rtlUnicodeStrlen(regex), regex); - regexPattern += regexStr; + regexPattern = std::string(regexStr, regexStrLen); rtlFree(regexStr); } failWithPCRE2Error(errCode, msgPrefix, regexPattern.c_str(), errOffset);