You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// "baz\0"// 012 3
m_pString[nIndex + 1] = 0; // index of \0 in "baz\0" = 3, which means nIndex here = 2SetLength( nIndex + 2 ); // since nIndex here = 2, nIndex + 2 = 4, and "baz\0" is indeed 4 characters long
CUtlString::SetLength( int nLen ) accepts literal buffer length, including the string null-terminator, you can verify this by checking its code where it calls AllocMemory( nLen );, implying that this buffer size should be enough for the '\0' as well.
Both overloads set an excess length by 1 more character when any trimming succeeds:
source-sdk-2013/src/tier1/utlstring.cpp
Line 538 in 0565403
source-sdk-2013/src/tier1/utlstring.cpp
Line 571 in 0565403
Should be changed to
SetLength( <index var> + 1 );
The text was updated successfully, but these errors were encountered: