mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
98706d79d4
commit
aa321cd887
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue