Move index check before usage, use std::size

According to cppchecker's `arrayIndexThenCheck` error:

```
src\game\client\race.cpp:24:30: style: Array index 'i' is used before limits check. [arrayIndexThenCheck]
  for(int i = 0; isdigit(pStr[i]) && i < 3; i++)
                             ^
```
This commit is contained in:
Robert Müller 2022-11-13 15:53:54 +01:00
parent 98706d79d4
commit aa321cd887

View file

@ -21,7 +21,7 @@ int CRaceHelper::TimeFromSecondsStr(const char *pStr)
{
pStr++;
static const int s_aMult[3] = {100, 10, 1};
for(int i = 0; isdigit(pStr[i]) && i < 3; i++)
for(size_t i = 0; i < std::size(s_aMult) && isdigit(pStr[i]); i++)
Time += (pStr[i] - '0') * s_aMult[i];
}
return Time;