Skip to content

Commit

Permalink
src: simplify bound check in ParseArrayIndex
Browse files Browse the repository at this point in the history
PR-URL: #42306
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
tniessen authored and bengl committed Mar 21, 2022
1 parent 9500e58 commit 8b84e68
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b84e68

Please sign in to comment.