2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +03:00

Fixed: StripUnprintableWorker did not count the null terminator

This commit is contained in:
s1lentq 2022-07-10 15:47:56 +07:00
parent be0e1c843b
commit e9045e3b63

View File

@ -461,7 +461,7 @@ static uchar16 *StripWhitespaceWorker(uchar16 *pwch, int cchLength, bool *pbStri
// walk backwards from the end of the string, killing any whitespace // walk backwards from the end of the string, killing any whitespace
*pbStrippedWhitespace = false; *pbStrippedWhitespace = false;
uchar16 *pwchEnd = pwch + cchLength; uchar16 *pwchEnd = pwch + cchLength - 1;
while (--pwchEnd >= pwch) while (--pwchEnd >= pwch)
{ {
if (!iswspace(*pwchEnd) && !Q_IsMeanSpaceW(*pwchEnd)) if (!iswspace(*pwchEnd) && !Q_IsMeanSpaceW(*pwchEnd))
@ -505,7 +505,7 @@ uchar16 *__cdecl StripUnprintableWorker(uchar16 *pwch, int *pLength, bool *pStri
*pStripped = rPos != wPos; *pStripped = rPos != wPos;
if (*pStripped) if (*pStripped)
*pLength = wPos - pwch; *pLength = (wPos - pwch) + 1; // null termination
return pwch; return pwch;
} }