Fix mDNS int parse crash, print errno on TCP connection failure

This commit is contained in:
2026-02-28 22:37:58 -05:00
parent a2f69f2183
commit 9a0d2c2f99
4 changed files with 27 additions and 6 deletions

View File

@@ -7,6 +7,8 @@
#include <sstream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
inline std::vector<std::string> split(const std::string &str, const char delimiter) {
std::vector<std::string> result;
@@ -20,4 +22,15 @@ inline std::vector<std::string> split(const std::string &str, const char delimit
return result;
}
inline bool is_integer(const std::string& s) {
if (s.empty()) return false;
size_t start = 0;
if (s[0] == '-' || s[0] == '+')
start = 1;
return start < s.size() &&
std::all_of(s.begin() + start, s.end(), ::isdigit);
}
#endif // STRING_H