Avoid raising an exception in case of an invalid text attribute

This commit is contained in:
Vibhav Pant
2023-09-11 17:39:03 +05:30
parent 6e524684a6
commit bcbcaa54a2
@@ -52,6 +52,7 @@ void ServiceBrowser::onItemNew(const int32_t &interface,
size_t pos = attr_str.find('=');
if (pos == 0 || pos == std::string::npos || pos == attr_str.size() - 1) {
NEARBY_LOGS(WARNING) << " found invalid text attribute: " << attr_str;
continue;
}
info.SetTxtRecord(attr_str.substr(0, pos), attr_str.substr(pos + 1));
@@ -94,6 +95,7 @@ void ServiceBrowser::onItemRemove(
size_t pos = attr_str.find('=');
if (pos == 0 || pos == std::string::npos || pos == attr_str.size() - 1) {
NEARBY_LOGS(WARNING) << " found invalid text attribute: " << attr_str;
continue;
}
info.SetTxtRecord(attr_str.substr(0, pos), attr_str.substr(pos + 1));