From 57df19b6e08bb7615011c6c9dc9759b9477b1f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Wed, 27 Sep 2017 11:51:35 +0300 Subject: [PATCH] url: fix remaining calculation Fix remaining calculation in the PercentDecode function to match the definition in URL standard: https://url.spec.whatwg.org/#remaining PR-URL: https://github.com/nodejs/node/pull/15637 Reviewed-By: James M Snell Reviewed-By: Timothy Gu --- src/node_url.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_url.cc b/src/node_url.cc index e23c1e6cbf2885..c8a4427eb60fb9 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -518,7 +518,7 @@ static inline void PercentDecode(const char* input, while (pointer < end) { const char ch = pointer[0]; - size_t remaining = (end - pointer) + 1; + const size_t remaining = end - pointer - 1; if (ch != '%' || remaining < 2 || (ch == '%' && (!IsASCIIHexDigit(pointer[1]) ||