File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2179,10 +2179,8 @@ void GetServers(const FunctionCallbackInfo<Value>& args) {
21792179 if (bracket_end != std::string::npos) {
21802180 host = entry.substr (1 , bracket_end - 1 );
21812181 if (bracket_end + 1 < entry.size () && entry[bracket_end + 1 ] == ' :' ) {
2182- try {
2183- port = std::stoi (entry.substr (bracket_end + 2 ));
2184- } catch (...) { /* ignore */
2185- }
2182+ int parsed = std::atoi (entry.substr (bracket_end + 2 ).c_str ());
2183+ if (parsed > 0 ) port = parsed;
21862184 }
21872185 } else {
21882186 host = entry; // fallback if malformed
@@ -2195,10 +2193,8 @@ void GetServers(const FunctionCallbackInfo<Value>& args) {
21952193 auto first_colon = entry.find (' :' );
21962194 if (colon != std::string::npos && colon == first_colon) {
21972195 host = entry.substr (0 , colon);
2198- try {
2199- port = std::stoi (entry.substr (colon + 1 ));
2200- } catch (...) { /* ignore */
2201- }
2196+ int parsed = std::atoi (entry.substr (colon + 1 ).c_str ());
2197+ if (parsed > 0 ) port = parsed;
22022198 } else {
22032199 /* no port, or IPv6 addr without brackets */
22042200 host = entry;
You can’t perform that action at this time.
0 commit comments