sct: qRound with param bigger than max int is undefined

oss-fuzz/399667098
This commit is contained in:
Albert Astals Cid
2025-03-03 21:51:03 +01:00
committed by Mirco Miranda
parent 5d2540c135
commit b28baa4a1e
2 changed files with 13 additions and 4 deletions

View File

@ -207,10 +207,10 @@ public:
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
if (ok && v > 0) {
if (m_pb._unitsOfMeasurement) { // Inches
return qRound(width() / v / 25.4 * 1000);
return qRoundOrZero(width() / v / 25.4 * 1000);
}
// Millimeters
return qRound(width() / v * 1000);
return qRoundOrZero(width() / v * 1000);
}
return 0;
}
@ -221,10 +221,10 @@ public:
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
if (ok && v > 0) {
if (m_pb._unitsOfMeasurement) { // Inches
return qRound(height() / v / 25.4 * 1000);
return qRoundOrZero(height() / v / 25.4 * 1000);
}
// Millimeters
return qRound(height() / v * 1000);
return qRoundOrZero(height() / v * 1000);
}
return 0;
}