From 27b81f30b4b623ae518415feb38721eb4d41ab70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 14 Mar 2022 17:36:39 +0100 Subject: [PATCH] src: simplify bound check in ParseArrayIndex PR-URL: https://github.com/nodejs/node/pull/42306 Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen Reviewed-By: James M Snell --- src/node_buffer.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index be9324a8bd82ab..215bd8003aabe1 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -220,9 +220,8 @@ inline MUST_USE_RESULT Maybe ParseArrayIndex(Environment* env, return Just(false); // Check that the result fits in a size_t. - const uint64_t kSizeMax = static_cast(static_cast(-1)); // coverity[pointless_expression] - if (static_cast(tmp_i) > kSizeMax) + if (static_cast(tmp_i) > std::numeric_limits::max()) return Just(false); *ret = static_cast(tmp_i);