diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 402fdace5..7f452ec4a 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1191,13 +1191,18 @@ void Session::processBannedIPs(lt::ip_filter &filter) void Session::adjustLimits(lt::settings_pack &settingsPack) const { // Internally increase the queue limits to ensure that the magnet is started - const int maxDownloads = maxActiveDownloads(); - const int maxActive = maxActiveTorrents(); + const auto adjustLimit = [this](const int limit) -> int + { + if (limit <= -1) + return limit; + // check for overflow: (limit + m_extraLimit) < std::numeric_limits::max() + return (m_extraLimit < (std::numeric_limits::max() - limit)) + ? (limit + m_extraLimit) + : std::numeric_limits::max(); + }; - settingsPack.set_int(lt::settings_pack::active_downloads - , maxDownloads > -1 ? maxDownloads + m_extraLimit : maxDownloads); - settingsPack.set_int(lt::settings_pack::active_limit - , maxActive > -1 ? maxActive + m_extraLimit : maxActive); + settingsPack.set_int(lt::settings_pack::active_downloads, adjustLimit(maxActiveDownloads())); + settingsPack.set_int(lt::settings_pack::active_limit, adjustLimit(maxActiveTorrents())); } void Session::applyBandwidthLimits(lt::settings_pack &settingsPack) const diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index c0eb5193a..f655f226f 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -2442,10 +2442,7 @@ Disable encryption: Only connect to peers without protocol encryption -1 - 999 - - - 3 + 2147483647 @@ -2465,10 +2462,7 @@ Disable encryption: Only connect to peers without protocol encryption -1 - 999 - - - 3 + 2147483647 @@ -2488,10 +2482,7 @@ Disable encryption: Only connect to peers without protocol encryption -1 - 999 - - - 5 + 2147483647