[jira] [Commented] (PDFBOX-1586) IndexOutOfBoundsException when saving a document (at random)

2013-06-10 Thread Andrew Dale (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-1586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13679435#comment-13679435
 ] 

Andrew Dale commented on PDFBOX-1586:
-

Even though the bug has been set to fixed in the 1.8.2 release of PDFBox, it is 
in my opinion still there.  A simplified test case is:

@Test
public void testPdfBox2() throws Exception {
PDDocument returnDocument = new PDDocument();
String outputFilename = /tmp/output.pdf;

ListInteger pages = Arrays.asList(1, 2, 3, 4, 5);

try {
// get/load current document
PDDocument currentPdf = PDDocument.load(new File(/tmp/input.pdf));

@SuppressWarnings(unchecked)
ListPDPage currentDocumentPages = 
currentPdf.getDocumentCatalog().getAllPages();

for (Integer currentPage : pages) {
returnDocument.importPage(currentDocumentPages.get(currentPage 
- 1));
}

currentPdf.close(); // cause of the problem, and everything works 
ok if this is closed after the returnDocument.save and returnDocument.close is 
called.

} finally {
returnDocument.save(outputFilename);
returnDocument.close();
}
}  

This gives me the following stacktrace:

org.apache.pdfbox.exceptions.COSVisitorException: 
java.lang.IndexOutOfBoundsException: Index: 72, Size: 0
at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1354)
at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:217)
at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
at 
org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:525)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:435)
at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1122)
at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:552)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1501)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1324)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1305)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1292)
at com.test.PdfBoxTest.testPdfBox2(PdfBoxTest.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IndexOutOfBoundsException: Index: 72, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at 
org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
at 
org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)

[jira] [Updated] (PDFBOX-1634) [PATCH] Adobe reader crash due to wrong length

2013-06-10 Thread simon steiner (JIRA)

 [ 
https://issues.apache.org/jira/browse/PDFBOX-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

simon steiner updated PDFBOX-1634:
--

Attachment: pdfcrash2.patch

 [PATCH] Adobe reader crash due to wrong length
 --

 Key: PDFBOX-1634
 URL: https://issues.apache.org/jira/browse/PDFBOX-1634
 Project: PDFBox
  Issue Type: Bug
Reporter: simon steiner
 Attachments: pdfcrash2.patch


 Adobe reader 9 and 10 crash because length inside source pdf was wrong

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Created] (PDFBOX-1634) [PATCH] Adobe reader crash due to wrong length

2013-06-10 Thread simon steiner (JIRA)
simon steiner created PDFBOX-1634:
-

 Summary: [PATCH] Adobe reader crash due to wrong length
 Key: PDFBOX-1634
 URL: https://issues.apache.org/jira/browse/PDFBOX-1634
 Project: PDFBox
  Issue Type: Bug
Reporter: simon steiner
 Attachments: pdfcrash2.patch

Adobe reader 9 and 10 crash because length inside source pdf was wrong

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Updated] (PDFBOX-1634) [PATCH] Adobe reader crash due to wrong length

2013-06-10 Thread simon steiner (JIRA)

 [ 
https://issues.apache.org/jira/browse/PDFBOX-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

simon steiner updated PDFBOX-1634:
--

Description: 
Adobe reader 9 and 10 crash because length inside source pdf was wrong

Source pdf has length of 174, should be 172, this causes pdfbox to add q to 
end of stream and crash reader

Im running using fop test.fo out.pdf

/Type /XObject
/Resources 5125 0 R
/Subtype /Form
/BBox [0 0 413.3900146484 17.450845]
/Matrix [1 0 0 1 0 0]
/Length 5126 0 R
/FormType 1

stream
q Q /Tx BMC q 0 0 413.39 15.46 re W n q BT 1 0 0 1 2 5.46 Tm /CourierNewPSMT 10 
Tf 0 g ($17,500 TSP Pre-Tax Contributions or Roth \(After Tax\) Contributio)Tj 
0 g ET Q EMC
endstream

5126 0 obj
174
endobj

  was:
Adobe reader 9 and 10 crash because length inside source pdf was wrong

Source pdf has length of 174, should be 172, this causes pdfbox to add q to 
end of stream and crash reader

/Type /XObject
/Resources 5125 0 R
/Subtype /Form
/BBox [0 0 413.3900146484 17.450845]
/Matrix [1 0 0 1 0 0]
/Length 5126 0 R
/FormType 1

stream
q Q /Tx BMC q 0 0 413.39 15.46 re W n q BT 1 0 0 1 2 5.46 Tm /CourierNewPSMT 10 
Tf 0 g ($17,500 TSP Pre-Tax Contributions or Roth \(After Tax\) Contributio)Tj 
0 g ET Q EMC
endstream

5126 0 obj
174
endobj


 [PATCH] Adobe reader crash due to wrong length
 --

 Key: PDFBOX-1634
 URL: https://issues.apache.org/jira/browse/PDFBOX-1634
 Project: PDFBox
  Issue Type: Bug
Reporter: simon steiner
 Attachments: pdfcrash2.patch


 Adobe reader 9 and 10 crash because length inside source pdf was wrong
 Source pdf has length of 174, should be 172, this causes pdfbox to add q to 
 end of stream and crash reader
 Im running using fop test.fo out.pdf
 /Type /XObject
 /Resources 5125 0 R
 /Subtype /Form
 /BBox [0 0 413.3900146484 17.450845]
 /Matrix [1 0 0 1 0 0]
 /Length 5126 0 R
 /FormType 1
 
 stream
 q Q /Tx BMC q 0 0 413.39 15.46 re W n q BT 1 0 0 1 2 5.46 Tm /CourierNewPSMT 
 10 Tf 0 g ($17,500 TSP Pre-Tax Contributions or Roth \(After Tax\) 
 Contributio)Tj 0 g ET Q EMC
 endstream
 5126 0 obj
 174
 endobj

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Updated] (PDFBOX-1634) [PATCH] Adobe reader crash due to wrong length

2013-06-10 Thread simon steiner (JIRA)

 [ 
https://issues.apache.org/jira/browse/PDFBOX-1634?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

simon steiner updated PDFBOX-1634:
--

Description: 
Adobe reader 9 and 10 crash because length inside source pdf was wrong

Source pdf has length of 174, should be 172, this causes pdfbox to add q to 
end of stream and crash reader

/Type /XObject
/Resources 5125 0 R
/Subtype /Form
/BBox [0 0 413.3900146484 17.450845]
/Matrix [1 0 0 1 0 0]
/Length 5126 0 R
/FormType 1

stream
q Q /Tx BMC q 0 0 413.39 15.46 re W n q BT 1 0 0 1 2 5.46 Tm /CourierNewPSMT 10 
Tf 0 g ($17,500 TSP Pre-Tax Contributions or Roth \(After Tax\) Contributio)Tj 
0 g ET Q EMC
endstream

5126 0 obj
174
endobj

  was:Adobe reader 9 and 10 crash because length inside source pdf was wrong


 [PATCH] Adobe reader crash due to wrong length
 --

 Key: PDFBOX-1634
 URL: https://issues.apache.org/jira/browse/PDFBOX-1634
 Project: PDFBox
  Issue Type: Bug
Reporter: simon steiner
 Attachments: pdfcrash2.patch


 Adobe reader 9 and 10 crash because length inside source pdf was wrong
 Source pdf has length of 174, should be 172, this causes pdfbox to add q to 
 end of stream and crash reader
 /Type /XObject
 /Resources 5125 0 R
 /Subtype /Form
 /BBox [0 0 413.3900146484 17.450845]
 /Matrix [1 0 0 1 0 0]
 /Length 5126 0 R
 /FormType 1
 
 stream
 q Q /Tx BMC q 0 0 413.39 15.46 re W n q BT 1 0 0 1 2 5.46 Tm /CourierNewPSMT 
 10 Tf 0 g ($17,500 TSP Pre-Tax Contributions or Roth \(After Tax\) 
 Contributio)Tj 0 g ET Q EMC
 endstream
 5126 0 obj
 174
 endobj

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira