mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier1: properly fix V_SplitString2
Patch in commit 057a2c801a40c2f280193da9963b009adb9f75f6 was done incorrectly, causing intermittent string truncation as subtracting pFirstSeparator from pCurPos will leave with a window in the buffer of exactly that split string, but the previous patch subtracted another char from it whilst adding one in AllocString just for it to be nulled.
This commit is contained in:
parent
8c9d873fbe
commit
3fc1bcd2b7
@ -446,14 +446,13 @@ void V_SplitString2(const char* pString, const char** pSeparators, ssize_t nSepa
|
||||
|
||||
if (pFirstSeparator > pCurPos)
|
||||
{
|
||||
const ssize_t nLen = (pFirstSeparator-1) - pCurPos;
|
||||
const ssize_t nLen = pFirstSeparator - pCurPos;
|
||||
char* const pSplit = AllocString(pCurPos, nLen);
|
||||
|
||||
// We need to terminate the array here since we copy the string
|
||||
// from the list minus the delimiter, and AllocString assumes
|
||||
// the null is already in the source buffer (also reserving
|
||||
// space for it). therefore we need len+1 to terminate it.
|
||||
pSplit[nLen + 1] = '\0';
|
||||
// from the list minus the delimiter. AllocString adds 1 to len
|
||||
// or the null character.
|
||||
pSplit[nLen] = '\0';
|
||||
outStrings.AddToTail(pSplit);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user