You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by karthick g <ik...@gmail.com> on 2011/06/02 12:59:11 UTC
Patch for ArrayIndexOutOfBound Exception
Hi all ,
* I am very long time user of PDFBOX from 0.7.3 version.
* Current I am using the latest version(1.5.0).
* While running a Malformed PDF i came across ArrayIndexOutOfBound
Exception.
* I searched Mail archives i can not able to fix it .
* Finally I touched the code and made a slighter change. Now it is
extracting correct Page Numbers.
* Can you guide me if the method followed by me and the way i fix the bug is
correct.
* I attached the sample PDF with this mail .
*ORIGINAL CODE* *IN PDPageLabels.java
*public String[] getLabelsByPageIndices()
{
final String[] map = new String[doc.getNumberOfPages()];
computeLabels(new LabelHandler()
{
public void newLabel(int pageIndex, String label)
{
map[pageIndex] = label;
}
});
return map;
}*
**MODIFIED CODE* *IN PDPageLabels.java
** *public String[] getLabelsByPageIndices()
{
final String[] map = new String[doc.getNumberOfPages()];
computeLabels(new LabelHandler()
{
public void newLabel(int pageIndex, String label)
{
if(pageIndex < doc.getNumberOfPages()){
map[pageIndex] = label;
}
}
});
return map;
}
*I added a simple IF Loop and it works fine.
*Kindly guide me in this issue
Re: Patch for ArrayIndexOutOfBound Exception
Posted by Jukka Zitting <ju...@gmail.com>.
Hi,
On Thu, Jun 2, 2011 at 12:59 PM, karthick g <ik...@gmail.com> wrote:
> * Can you guide me if the method followed by me and the way i fix the bug is
> correct.
Looks good to me!
Could you file this as an issue in
https://issues.apache.org/jira/browse/PDFBOX and attach your fix and
the troublesome PDF there? That way we can better track the problem
and properly attribute the fix to you.
BR,
Jukka Zitting