mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Fix possible variable overflow
This commit is contained in:
parent
1eb26bd78b
commit
7867cf68f9
1 changed files with 5 additions and 5 deletions
|
@ -60,16 +60,16 @@ public:
|
|||
pix.fill();
|
||||
pixmap = pix;
|
||||
} else {
|
||||
const int nb_pieces = pieces.size();
|
||||
const qulonglong nb_pieces = pieces.size();
|
||||
// Reduce the number of pieces before creating the pixmap
|
||||
// otherwise it can crash when there are too many pieces
|
||||
if(nb_pieces > width()) {
|
||||
if(nb_pieces > (uint)width()) {
|
||||
const int ratio = floor(nb_pieces/(double)width());
|
||||
std::vector<bool> scaled_pieces;
|
||||
std::vector<bool> scaled_downloading;
|
||||
for(int i=0; i<nb_pieces; i+= ratio) {
|
||||
for(qulonglong i=0; i<nb_pieces; i+= ratio) {
|
||||
bool have = true;
|
||||
for(int j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||
if(!pieces[i]) { have = false; break; }
|
||||
}
|
||||
scaled_pieces.push_back(have);
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
scaled_downloading.push_back(false);
|
||||
} else {
|
||||
bool downloading = false;
|
||||
for(int j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||
if(downloading_pieces[i]) { downloading = true; break; }
|
||||
}
|
||||
scaled_downloading.push_back(downloading);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue