diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-06-05 17:25:22 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-06-05 17:25:22 +0000 |
commit | 4ffc419764a736cd489c21dd6895b2bf162cbf4e (patch) | |
tree | 281900679f19bd0f0fec31322d726426f00017ae /cups/pwg-media.c | |
parent | 766a82295781e5923fda8329c981959b7b77558b (diff) | |
download | cups-4ffc419764a736cd489c21dd6895b2bf162cbf4e.tar.gz |
<rdar://problem/14065748> pwgMediaForPWG: roll_max_36.1025x3622.0472in becomes 91700 x 180568 instead of 91700 x 9199999
Convert fractional portion separately to avoid integer overflow.
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11011 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/pwg-media.c')
-rw-r--r-- | cups/pwg-media.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cups/pwg-media.c b/cups/pwg-media.c index 3a4cb9709..49f69297f 100644 --- a/cups/pwg-media.c +++ b/cups/pwg-media.c @@ -1132,6 +1132,7 @@ pwg_scan_measurement( int denom) /* I - Denominator from units */ { int value = 0, /* Measurement value */ + fractional = 0, /* Fractional value */ divisor = 1, /* Fractional divisor */ digits = 10 * numer * denom; /* Maximum fractional value to read */ @@ -1153,7 +1154,7 @@ pwg_scan_measurement( while (divisor < digits && *buf >= '0' && *buf <= '9') { - value = value * 10 + (*buf++) - '0'; + fractional = fractional * 10 + (*buf++) - '0'; divisor *= 10; } @@ -1168,7 +1169,7 @@ pwg_scan_measurement( if (bufptr) *bufptr = (char *)buf; - return (value * numer / denom / divisor); + return (value * numer / denom + fractional * numer / denom / divisor); } |