src: simplify bound check in ParseArrayIndex

PR-URL: https://github.com/nodejs/node/pull/42306
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Tobias Nießen authored and Bryan English committed 2022-03-20 23:04:30 -04:00
1 parent 9500e5862e
commit 8b84e68cbd
1 file changed
+1 -2
+1 -2
View File
@@ -220,9 +220,8 @@ inline MUST_USE_RESULT Maybe<bool> ParseArrayIndex(Environment* env,
return Just(false);
// Check that the result fits in a size_t.
const uint64_t kSizeMax = static_cast<uint64_t>(static_cast<size_t>(-1));
// coverity[pointless_expression]
if (static_cast<uint64_t>(tmp_i) > kSizeMax)
if (static_cast<uint64_t>(tmp_i) > std::numeric_limits<size_t>::max())
return Just(false);
*ret = static_cast<size_t>(tmp_i);