From 00981790bc39e9a0674feec19ffa792329bb077c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 23 Apr 2012 17:00:03 +0200 Subject: Fixed assertion when SRV weights are all 0. diff --git a/Swiften/Network/DomainNameServiceQuery.cpp b/Swiften/Network/DomainNameServiceQuery.cpp index eb999e0..f7ffecc 100644 --- a/Swiften/Network/DomainNameServiceQuery.cpp +++ b/Swiften/Network/DomainNameServiceQuery.cpp @@ -52,7 +52,7 @@ void DomainNameServiceQuery::sortResults(std::vector 1) { int weightSum = std::accumulate(i, next, 0, WeightAccumulator()); std::vector probabilities; - std::transform(i, next, std::back_inserter(probabilities), WeightToProbability(weightSum)); + std::transform(i, next, std::back_inserter(probabilities), WeightToProbability(weightSum > 0 ? weightSum : 1)); // Shuffling the result array and the probabilities in parallel for (size_t j = 0; j < probabilities.size(); ++j) { -- cgit v0.10.2-6-g49f6