Fixed potential overflow in C++ code, in worst case when int type is int16.

This commit is contained in:
Project Nayuki 2017-04-17 02:02:33 +00:00
parent 5071995ab7
commit b7a4605e44
1 changed files with 1 additions and 1 deletions

View File

@ -258,7 +258,7 @@ void qrcodegen::QrCode::drawVersion() {
int rem = version; // version is uint6, in the range [7, 40]
for (int i = 0; i < 12; i++)
rem = (rem << 1) ^ ((rem >> 11) * 0x1F25);
int data = version << 12 | rem; // uint18
long data = (long)version << 12 | rem; // uint18
if (data >> 18 != 0)
throw "Assertion error";