diff options
author | irungentoo <irungentoo@gmail.com> | 2015-11-19 15:10:20 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-11-19 15:10:20 -0500 |
commit | 548fafc4ddef6c60d79498d59a576bd66e6a0373 (patch) | |
tree | cca4e26077a841fe22c15300d0f1a366d89ab3e1 | |
parent | 0c29c0012574b76f3e890a96ad065f1a471c5b33 (diff) |
Fixed division by 0.
-rw-r--r-- | toxcore/net_crypto.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index bd290563..83b8b8cf 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2226,6 +2226,10 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2226 | uint32_t npackets = num_packets_array(&conn->send_array); | 2226 | uint32_t npackets = num_packets_array(&conn->send_array); |
2227 | double min_speed = 1000.0 * (((double)(total_sent)) / ((double)(CONGESTION_QUEUE_ARRAY_SIZE) * | 2227 | double min_speed = 1000.0 * (((double)(total_sent)) / ((double)(CONGESTION_QUEUE_ARRAY_SIZE) * |
2228 | PACKET_COUNTER_AVERAGE_INTERVAL)); | 2228 | PACKET_COUNTER_AVERAGE_INTERVAL)); |
2229 | |||
2230 | if (min_speed < CRYPTO_PACKET_MIN_RATE) | ||
2231 | min_speed = CRYPTO_PACKET_MIN_RATE; | ||
2232 | |||
2229 | double send_array_ratio = (((double)npackets) / min_speed); | 2233 | double send_array_ratio = (((double)npackets) / min_speed); |
2230 | 2234 | ||
2231 | //TODO: Improve formula? | 2235 | //TODO: Improve formula? |