Skip to content

Commit

Permalink
Fixed: StripUnprintableWorker did not count the null terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jul 10, 2022
1 parent be0e1c8 commit e9045e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rehlds/engine/unicode_strtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e9045e3

Please sign in to comment.