Bug 47641 - int overflow with large font size values
Summary: int overflow with large font size values
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fonts (show other bugs)
Version: trunk
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-04 10:34 UTC by Jeremias Maerki
Modified: 2012-04-07 01:51 UTC (History)
0 users



Attachments
FO File that demonstrates the int overflow problem (2.50 KB, application/octet-stream)
2009-08-04 10:34 UTC, Jeremias Maerki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremias Maerki 2009-08-04 10:34:45 UTC
Created attachment 24099 [details]
FO File that demonstrates the int overflow problem

A rather nasty bug: In XSL-FO, we usually have font sizes under 11'000 points.
No problem. Switch to SVG and define a viewBox with relatively high values and
you can quickly end up with a font size of 11'000 (units not points). It
happened to me when I ran an SVG that was produced by the SVG document handler
in the FOP sandbox. That one just sets up FOP's internal millipoint coordinate
system in SVG. No SVG editor/viewer has a problem with that.

So, the problem is, for example, the generated Helvetica class' getWidth(int i,
int size) method which returns an int. Multiply a number in the 1000 range with
the font size that has been multiplied by 1000 (pt -> mpt conversion for normal
FO).

950 * (1000 * 11000) = 10450000000 (0x26EDE5880)

That result is bigger than a 32-bit int.

For comparison, the usual case in FO:
950 * (1000 * 11) = 10450000 (0x9F7450)

I've locally added long variants of the problematic methods (getWidth() ->
getWidthLong()) to see if this really solves the problem and it does indeed.
Just replacing int with long everywhere is not a good idea because of
backwards-compatibility. We know that some people are using these classes
outside of FOP. To me, the additional long variants look like the cleanest
solution, but maybe someone has a better solution.
Comment 1 Glenn Adams 2012-04-07 01:41:33 UTC
resetting P2 open bugs to P3 pending further review