mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-23 06:35:24 -07:00
Merge pull request #3229 from Chocobo1/dev6_v320
Fix potential out-of-bound access in misc::friendlyUnit()
This commit is contained in:
commit
c1a47279af
2 changed files with 4 additions and 5 deletions
|
@ -296,8 +296,10 @@ QString misc::friendlyUnit(qreal val, bool is_speed)
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
return QCoreApplication::translate("misc", "Unknown", "Unknown (size)");
|
return QCoreApplication::translate("misc", "Unknown", "Unknown (size)");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(val >= 1024. && i++<6)
|
while(val >= 1024. && i < 4) {
|
||||||
val /= 1024.;
|
val /= 1024.;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
QString ret;
|
QString ret;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
ret = QString::number((long)val) + " " + QCoreApplication::translate("misc", units[0].source, units[0].comment);
|
ret = QString::number((long)val) + " " + QCoreApplication::translate("misc", units[0].source, units[0].comment);
|
||||||
|
|
|
@ -105,10 +105,7 @@ void QAlertDispatcher::dispatch(QSharedPointer<Tag> tag,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool was_empty = that->alerts.empty();
|
bool was_empty = that->alerts.empty();
|
||||||
|
that->alerts.push_back(alert_ptr.release());
|
||||||
that->alerts.push_back(alert_ptr.get());
|
|
||||||
alert_ptr.release();
|
|
||||||
|
|
||||||
if (was_empty)
|
if (was_empty)
|
||||||
that->alerts_condvar.wakeAll();
|
that->alerts_condvar.wakeAll();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue