mirror of
https://github.com/openharmony/third_party_qrcodegen.git
synced 2026-07-18 09:44:36 -04:00
Fixed potential overflow in C and C++ code, in worst case when int type is int16.
This commit is contained in:
+1
-1
@@ -483,7 +483,7 @@ long qrcodegen::QrCode::getPenaltyScore() const {
|
||||
}
|
||||
int total = size * size;
|
||||
// Find smallest k such that (45-5k)% <= dark/total <= (55+5k)%
|
||||
for (int k = 0; black*20 < (9-k)*total || black*20 > (11+k)*total; k++)
|
||||
for (int k = 0; black*20L < (9L-k)*total || black*20L > (11L+k)*total; k++)
|
||||
result += PENALTY_N4;
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user