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 <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
tniessen authored Mar 14, 2022
1 parent d90ceb2 commit afcfaa0
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 afcfaa0

Please sign in to comment.