From 26cb71458d6cc791a71f11f0a29e51b11d35b9c0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 14 Mar 2015 01:35:06 +0800 Subject: [PATCH 1/2] Simplify code --- src/core/qtlibtorrent/alertdispatcher.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/qtlibtorrent/alertdispatcher.cpp b/src/core/qtlibtorrent/alertdispatcher.cpp index cf5618019..ce7180b5d 100644 --- a/src/core/qtlibtorrent/alertdispatcher.cpp +++ b/src/core/qtlibtorrent/alertdispatcher.cpp @@ -105,10 +105,7 @@ void QAlertDispatcher::dispatch(QSharedPointer tag, return; bool was_empty = that->alerts.empty(); - - that->alerts.push_back(alert_ptr.get()); - alert_ptr.release(); - + that->alerts.push_back(alert_ptr.release()); if (was_empty) that->alerts_condvar.wakeAll(); From 7892f37d3e73b4ed1f3a085182bae5e193f2d4c5 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 17 Jun 2015 08:10:25 +0800 Subject: [PATCH 2/2] Fix potential out-of-bound access of units[i] --- src/core/misc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/misc.cpp b/src/core/misc.cpp index 42414d8f6..dc87c6dfb 100644 --- a/src/core/misc.cpp +++ b/src/core/misc.cpp @@ -296,8 +296,10 @@ QString misc::friendlyUnit(qreal val, bool is_speed) if (val < 0) return QCoreApplication::translate("misc", "Unknown", "Unknown (size)"); int i = 0; - while(val >= 1024. && i++<6) + while(val >= 1024. && i < 4) { val /= 1024.; + ++i; + } QString ret; if (i == 0) ret = QString::number((long)val) + " " + QCoreApplication::translate("misc", units[0].source, units[0].comment);