Wstring view overrun (#884)
This commit is contained in:
committed by
Matt Cooley
parent
fb18b639e3
commit
563404fd99
@@ -215,10 +215,12 @@ int CCalcEngine::IsNumberInvalid(const wstring& numberString, int iMaxExp, int i
|
||||
\****************************************************************************/
|
||||
vector<uint32_t> CCalcEngine::DigitGroupingStringToGroupingVector(wstring_view groupingString)
|
||||
{
|
||||
vector<uint32_t> grouping{};
|
||||
vector<uint32_t> grouping;
|
||||
uint32_t currentGroup = 0;
|
||||
wchar_t* next = nullptr;
|
||||
for (const wchar_t* itr = groupingString.data(); *itr != L'\0'; ++itr)
|
||||
const wchar_t* begin = groupingString.data();
|
||||
const wchar_t* end = begin + groupingString.length();
|
||||
for (auto itr = begin; itr != end; ++itr)
|
||||
{
|
||||
// Try to parse a grouping number from the string
|
||||
currentGroup = wcstoul(itr, &next, 10);
|
||||
@@ -232,7 +234,7 @@ vector<uint32_t> CCalcEngine::DigitGroupingStringToGroupingVector(wstring_view g
|
||||
// If we found a grouping and aren't at the end of the string yet,
|
||||
// jump to the next position in the string (the ';').
|
||||
// The loop will then increment us to the next character, which should be a number.
|
||||
if (next && (static_cast<size_t>(next - groupingString.data()) < groupingString.length()))
|
||||
if (next && (static_cast<size_t>(next - begin) < groupingString.length()))
|
||||
{
|
||||
itr = next;
|
||||
}
|
||||
|
Reference in New Issue
Block a user