Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleeight <leeight@gmail.com>2018-11-19 07:31:26 +0300
committerAnna Henningsen <anna@addaleax.net>2018-12-01 20:57:00 +0300
commitadbf9477eb244b0f83a705b06269705967194f03 (patch)
tree1d69b9665e912f3a6b2925e4998589c4a8f1676b /src/node_url.cc
parent82ceb5e4b1f0114361fca617799caa04725bee1b (diff)
src: use arraysize instead of hardcode number
PR-URL: https://github.com/nodejs/node/pull/24473 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/node_url.cc')
-rw-r--r--src/node_url.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index 57be5418aa5..b9fda6cf43e 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -787,10 +787,11 @@ inline bool ToASCII(const std::string& input, std::string* output) {
void URLHost::ParseIPv6Host(const char* input, size_t length) {
CHECK_EQ(type_, HostType::H_FAILED);
- for (unsigned n = 0; n < 8; n++)
+ unsigned size = arraysize(value_.ipv6);
+ for (unsigned n = 0; n < size; n++)
value_.ipv6[n] = 0;
uint16_t* piece_pointer = &value_.ipv6[0];
- uint16_t* const buffer_end = piece_pointer + 8;
+ uint16_t* const buffer_end = piece_pointer + size;
uint16_t* compress_pointer = nullptr;
const char* pointer = input;
const char* end = pointer + length;
@@ -952,7 +953,7 @@ void URLHost::ParseIPv4Host(const char* input, size_t length, bool* is_ipv4) {
const char ch = pointer < end ? pointer[0] : kEOL;
const int remaining = end - pointer - 1;
if (ch == '.' || ch == kEOL) {
- if (++parts > 4)
+ if (++parts > static_cast<int>(arraysize(numbers)))
return;
if (pointer == mark)
return;