From e9045e3b6359d8bf2c2f4c0d57e4f7ff129beb2c Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sun, 10 Jul 2022 15:47:56 +0700 Subject: [PATCH] Fixed: StripUnprintableWorker did not count the null terminator --- rehlds/engine/unicode_strtools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/unicode_strtools.cpp b/rehlds/engine/unicode_strtools.cpp index 275c9af26..385cee971 100644 --- a/rehlds/engine/unicode_strtools.cpp +++ b/rehlds/engine/unicode_strtools.cpp @@ -461,7 +461,7 @@ static uchar16 *StripWhitespaceWorker(uchar16 *pwch, int cchLength, bool *pbStri // walk backwards from the end of the string, killing any whitespace *pbStrippedWhitespace = false; - uchar16 *pwchEnd = pwch + cchLength; + uchar16 *pwchEnd = pwch + cchLength - 1; while (--pwchEnd >= pwch) { if (!iswspace(*pwchEnd) && !Q_IsMeanSpaceW(*pwchEnd)) @@ -505,7 +505,7 @@ uchar16 *__cdecl StripUnprintableWorker(uchar16 *pwch, int *pLength, bool *pStri *pStripped = rPos != wPos; if (*pStripped) - *pLength = wPos - pwch; + *pLength = (wPos - pwch) + 1; // null termination return pwch; }