зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1431874 - Loop using a size_t index, not a pointer, to avoid undefined behavior computing an end pointer possibly outside the range of the underlying data. r=jonco
--HG-- extra : rebase_source : c877adc843c2e269742735f9af203278dfe9a973
This commit is contained in:
Родитель
dde07bbcac
Коммит
160f7db525
|
@ -3208,9 +3208,10 @@ template<class CharType>
|
|||
static size_t
|
||||
strnlen(const CharType* begin, size_t max)
|
||||
{
|
||||
for (const CharType* s = begin; s != begin + max; ++s)
|
||||
if (*s == 0)
|
||||
return s - begin;
|
||||
for (size_t i = 0; i < max; i++) {
|
||||
if (begin[i] == '\0')
|
||||
return i;
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче