mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
Fix possible variable overflow
This commit is contained in:
parent
1eb26bd78b
commit
7867cf68f9
@ -60,16 +60,16 @@ public:
|
|||||||
pix.fill();
|
pix.fill();
|
||||||
pixmap = pix;
|
pixmap = pix;
|
||||||
} else {
|
} else {
|
||||||
const int nb_pieces = pieces.size();
|
const qulonglong nb_pieces = pieces.size();
|
||||||
// Reduce the number of pieces before creating the pixmap
|
// Reduce the number of pieces before creating the pixmap
|
||||||
// otherwise it can crash when there are too many pieces
|
// 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());
|
const int ratio = floor(nb_pieces/(double)width());
|
||||||
std::vector<bool> scaled_pieces;
|
std::vector<bool> scaled_pieces;
|
||||||
std::vector<bool> scaled_downloading;
|
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;
|
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; }
|
if(!pieces[i]) { have = false; break; }
|
||||||
}
|
}
|
||||||
scaled_pieces.push_back(have);
|
scaled_pieces.push_back(have);
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
scaled_downloading.push_back(false);
|
scaled_downloading.push_back(false);
|
||||||
} else {
|
} else {
|
||||||
bool downloading = false;
|
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; }
|
if(downloading_pieces[i]) { downloading = true; break; }
|
||||||
}
|
}
|
||||||
scaled_downloading.push_back(downloading);
|
scaled_downloading.push_back(downloading);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user