mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-12 18:24:58 +08:00
Merge pull request #2719 from Chocobo1/dev6
Fix potential out-of-bound access in misc::friendlyUnit()
This commit is contained in:
commit
cf1a62cec3
@ -258,8 +258,10 @@ QString Utils::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);
|
||||||
|
Loading…
Reference in New Issue
Block a user