Skip to content

Commit afd4cb2

Browse files
committed
PDFBOX-4718: replace huge values as those are most likely invalid due to a malformed pdf
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921840 13f79535-47bb-0310-9956-ffa450edef68
1 parent b24e1f3 commit afd4cb2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDRectangle.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ public PDRectangle( BoundingBox box )
147147
public PDRectangle( COSArray array )
148148
{
149149
float[] values = Arrays.copyOf(array.toFloatArray(), 4);
150+
// replace huge values, most likely those are invalid due to a malformed pdf
151+
for (int i = 0; i < values.length; i++)
152+
{
153+
if (Math.abs(values[i]) > Integer.MAX_VALUE)
154+
{
155+
values[i] = values[i] > 0 ? Integer.MAX_VALUE : -Integer.MAX_VALUE;
156+
}
157+
}
150158
rectArray = new COSArray(List.of(
151159
// we have to start with the lower left corner
152160
new COSFloat( Math.min(values[0],values[2] )),

0 commit comments

Comments
 (0)