mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-23 14:45:22 -07:00
Fix potential out-of-bound access of units[i]
This commit is contained in:
parent
26cb71458d
commit
7892f37d3e
1 changed files with 3 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue