From 61990c2aee32b6c2cfb5f8fef462dc89846c2a66 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 17 Apr 2020 13:36:57 +0200 Subject: [PATCH] Fixes #295: set default client port when unable to parse port string --- client_http.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client_http.hpp b/client_http.hpp index 1a87b03..23017ed 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -507,7 +507,12 @@ namespace SimpleWeb { } else { parsed_host_port.first = host_port.substr(0, host_end); - parsed_host_port.second = static_cast(stoul(host_port.substr(host_end + 1))); + try { + parsed_host_port.second = static_cast(stoul(host_port.substr(host_end + 1))); + } + catch(...) { + parsed_host_port.second = default_port; + } } return parsed_host_port; }