mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
sct: qRound with param bigger than max int is undefined
oss-fuzz/399667098
This commit is contained in:
parent
e98467d954
commit
d0f2635e10
@ -207,10 +207,10 @@ public:
|
|||||||
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
|
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
|
||||||
if (ok && v > 0) {
|
if (ok && v > 0) {
|
||||||
if (m_pb._unitsOfMeasurement) { // Inches
|
if (m_pb._unitsOfMeasurement) { // Inches
|
||||||
return qRound(width() / v / 25.4 * 1000);
|
return qRoundOrZero(width() / v / 25.4 * 1000);
|
||||||
}
|
}
|
||||||
// Millimeters
|
// Millimeters
|
||||||
return qRound(width() / v * 1000);
|
return qRoundOrZero(width() / v * 1000);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -221,10 +221,10 @@ public:
|
|||||||
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
|
auto v = QString::fromLatin1(pchar_t(res.data()), res.size()).toDouble(&ok);
|
||||||
if (ok && v > 0) {
|
if (ok && v > 0) {
|
||||||
if (m_pb._unitsOfMeasurement) { // Inches
|
if (m_pb._unitsOfMeasurement) { // Inches
|
||||||
return qRound(height() / v / 25.4 * 1000);
|
return qRoundOrZero(height() / v / 25.4 * 1000);
|
||||||
}
|
}
|
||||||
// Millimeters
|
// Millimeters
|
||||||
return qRound(height() / v * 1000);
|
return qRoundOrZero(height() / v * 1000);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,13 @@ inline QImage imageAlloc(qint32 width, qint32 height, const QImage::Format &form
|
|||||||
return imageAlloc(QSize(width, height), format);
|
return imageAlloc(QSize(width, height), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double qRoundOrZero(double d)
|
||||||
|
{
|
||||||
|
// If the value d is outside the range of int, the behavior is undefined.
|
||||||
|
if (d > std::numeric_limits<int>::max()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return qRound(d);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // UTIL_P_H
|
#endif // UTIL_P_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user