Avoid generating corrupt pdf output for out of range coordinates
The local qreal to string conversion would fail and produce unsyntactic output if the integer part exceeded the range of an unsigned int. Introduce check for that, and fall back to just output a 0 value instead in such cases. Testing indicates that there is no point in supporting values beyond 4G, as pdf readers do not seem to accept higher values anyway. As a driveby, also extend the check to catch all non-finite real values, not only nan. As a second driveby, simplify the splitting of a qreal into integer and fraction parts by just using the std library function for that. Fixes: QTBUG-117740 Pick-to: 6.6 6.5 Change-Id: I247b0612bd565fb2e6f47a182e74f19b8bb0d683 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
ebf1538fa6
commit
888be431da
@ -99,7 +99,7 @@ static void removeTransparencyFromBrush(QBrush &brush)
|
||||
const char *qt_real_to_string(qreal val, char *buf) {
|
||||
const char *ret = buf;
|
||||
|
||||
if (qIsNaN(val)) {
|
||||
if (!qIsFinite(val) || std::abs(val) > std::numeric_limits<quint32>::max()) {
|
||||
*(buf++) = '0';
|
||||
*(buf++) = ' ';
|
||||
*buf = 0;
|
||||
@ -110,8 +110,8 @@ const char *qt_real_to_string(qreal val, char *buf) {
|
||||
*(buf++) = '-';
|
||||
val = -val;
|
||||
}
|
||||
unsigned int ival = (unsigned int) val;
|
||||
qreal frac = val - (qreal)ival;
|
||||
qreal frac = std::modf(val, &val);
|
||||
quint32 ival(val);
|
||||
|
||||
int ifrac = (int)(frac * 1000000000);
|
||||
if (ifrac == 1000000000) {
|
||||
|
Loading…
Reference in New Issue
Block a user