summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-02-27 14:52:04 (GMT)
committerTobias Markmann <tm@ayena.de>2017-02-27 16:09:37 (GMT)
commit049a95e4e1a4e981cd7a9f9f591f04ce94178548 (patch)
treed9caca4c9ac78dce6dce57826c9c0fa2f9dbbd51 /Swiften/Network
parentfc8f5b31c22ed7af4f0e2473f269601a87a0438c (diff)
downloadswift-049a95e4e1a4e981cd7a9f9f591f04ce94178548.zip
swift-049a95e4e1a4e981cd7a9f9f591f04ce94178548.tar.bz2
Handle boost::bad_lexical_cast exception in HostAddressPort::toString()
Test-Information: Builds and unit tests pass on macOS 10.12.3 with Qt 5.7.1. Change-Id: I258ea7a70a025bc0ebf61eea7acd636e90fc8b1e
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/HostAddressPort.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Swiften/Network/HostAddressPort.cpp b/Swiften/Network/HostAddressPort.cpp
index a73b2ad..76c276e 100644
--- a/Swiften/Network/HostAddressPort.cpp
+++ b/Swiften/Network/HostAddressPort.cpp
@@ -19,5 +19,10 @@ HostAddressPort::HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint)
}
std::string HostAddressPort::toString() const {
- return getAddress().toString() + ":" + boost::lexical_cast<std::string>(getPort());
+ std::string portAsString;
+ try {
+ portAsString = boost::lexical_cast<std::string>(getPort());
+ } catch (boost::bad_lexical_cast&) {
+ }
+ return getAddress().toString() + ":" + portAsString;
}