mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Fix a crash by improving cutString() function
Remove an arbitrary MAX_PATH character limit Fixes #2727, closes #4037
This commit is contained in:
parent
0e60bd8957
commit
7a0dae5912
@ -651,38 +651,25 @@ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
|
|||||||
|
|
||||||
void cutString(const TCHAR* str2cut, vector<generic_string>& patternVect)
|
void cutString(const TCHAR* str2cut, vector<generic_string>& patternVect)
|
||||||
{
|
{
|
||||||
TCHAR str2scan[MAX_PATH];
|
if (str2cut == nullptr) return;
|
||||||
lstrcpy(str2scan, str2cut);
|
|
||||||
size_t len = lstrlen(str2scan);
|
|
||||||
bool isProcessing = false;
|
|
||||||
TCHAR *pBegin = nullptr;
|
|
||||||
|
|
||||||
for (size_t i = 0 ; i <= len ; ++i)
|
const TCHAR *pBegin = str2cut;
|
||||||
|
const TCHAR *pEnd = pBegin;
|
||||||
|
|
||||||
|
while (*pEnd != '\0')
|
||||||
{
|
{
|
||||||
switch(str2scan[i])
|
if (_istspace(*pEnd))
|
||||||
{
|
{
|
||||||
case ' ':
|
if (pBegin != pEnd)
|
||||||
case '\0':
|
patternVect.emplace_back(pBegin, pEnd);
|
||||||
{
|
pBegin = pEnd + 1;
|
||||||
if (isProcessing)
|
|
||||||
{
|
|
||||||
str2scan[i] = '\0';
|
|
||||||
patternVect.push_back(pBegin);
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
if (!isProcessing)
|
|
||||||
{
|
|
||||||
isProcessing = true;
|
|
||||||
pBegin = str2scan+i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
++pEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pBegin != pEnd)
|
||||||
|
patternVect.emplace_back(pBegin, pEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user