From 3ebfad0efbb26da096e55e4fe4eebffbca9059e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Sat, 8 Apr 2017 23:36:41 +0300 Subject: [PATCH] url_parser::parse_path(...): use size_t to store ptr2-ptr1 Previosly used int --- src/url.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/url.h b/src/url.h index 21d28b0..f86a6a1 100644 --- a/src/url.h +++ b/src/url.h @@ -1933,7 +1933,7 @@ inline void url_parser::parse_path(url_serializer& urls, const CharT* first, con // path state; includes: // 1. [ (/,\) - 1, 2, 3, 4 - [ 1 (if first segment), 2 ] ] // 2. [ 1 ... 4 ] - auto double_dot = [](const CharT* const pointer, const int len) -> bool { + auto double_dot = [](const CharT* const pointer, const size_t len) -> bool { if (len == 2) { return (pointer[0] == '.' && pointer[1] == '.'); } else if (len == 4) { @@ -1944,7 +1944,7 @@ inline void url_parser::parse_path(url_serializer& urls, const CharT* first, con } else return false; }; - auto single_dot = [](const CharT* const pointer, const int len) -> bool { + auto single_dot = [](const CharT* const pointer, const size_t len) -> bool { if (len == 1) { return pointer[0] == '.'; } else if (len == 3) { @@ -1960,7 +1960,8 @@ inline void url_parser::parse_path(url_serializer& urls, const CharT* first, con ? std::find_if(pointer, last, is_slash) : std::find(pointer, last, '/'); - int len = end_of_segment - pointer; + // end_of_segment >= pointer + const size_t len = end_of_segment - pointer; bool is_last = end_of_segment == last; // TODO-WARN: 1. If url is special and c is "\", validation error.