diff options
Diffstat (limited to 'Swiften/Network/GConfProxyProvider.cpp')
| -rw-r--r-- | Swiften/Network/GConfProxyProvider.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Swiften/Network/GConfProxyProvider.cpp b/Swiften/Network/GConfProxyProvider.cpp index eade450..7c31868 100644 --- a/Swiften/Network/GConfProxyProvider.cpp +++ b/Swiften/Network/GConfProxyProvider.cpp @@ -3,11 +3,11 @@ * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016-2017 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Network/GConfProxyProvider.h> @@ -19,10 +19,12 @@ extern "C" { #include <gconf/gconf-client.h> } +#include <boost/numeric/conversion/cast.hpp> + #include <Swiften/Base/Log.h> namespace Swift { GConfProxyProvider::GConfProxyProvider() { @@ -48,17 +50,21 @@ HostAddressPort GConfProxyProvider::getSOCKS5Proxy() const { return socksProxy; } HostAddressPort GConfProxyProvider::getFromGConf(const char* gcHost, const char* gcPort) { std::string address; - int port = 0; + unsigned short port = 0; gchar* str; GConfClient* client = gconf_client_get_default(); str = gconf_client_get_string(client, gcHost, NULL); - port = static_cast<int> (gconf_client_get_int(client, gcPort, NULL)); + try { + port = boost::numeric_cast<unsigned short>(gconf_client_get_int(client, gcPort, NULL)); + } + catch (const boost::numeric::bad_numeric_cast&) { + } if(str) { address = static_cast<char*> (str); g_free(str); } |
Swift