[poppler] Confused about Hints::getPageObjectNum

Albert Astals Cid aacid at kde.org
Sun Jun 10 13:39:17 PDT 2012


El Diumenge, 10 de juny de 2012, a les 20:35:29, Hib Eris va escriure:
> Hi Albert,
> 
> On Sun, Jun 10, 2012 at 6:44 PM, Albert Astals Cid <aacid at kde.org> wrote:
> > Hi Hib, I've been having a look at the implementation of
> > Hints::getPageObjectNum
> > 
> > int Hints::getPageObjectNum(int page) {
> >  if ((page < 1) || (page > nPages)) return 0;
> > 
> >  if (page-1 > pageFirst)
> >    return pageObjectNum[page-1];
> >  else if (page-1 < pageFirst)
> >    return pageObjectNum[page];
> >  else
> >    return pageObjectNum[0];
> > }
> 
> The idea is that in pageObjectNum[0] you will find the object number
> of the page specified as the first page in the linearization table. In
> pageObjectNum[1..pageFirst-1] you will find page 1 .. page (pageFirst
> -1).
> In pageObjectNum[pageFirst.. nPages-1] you will find page
> (pageFirst+1) ..  page nPages.
> 
> > And i'm quite confused about it since for example if
> > nPages = 2
> > pageFirst = 3
> > page = 2
> > (I know probably invalid values, but they could be in a pdf, right)
> > it will end up returning pageObjectNum[2] and it would crash.
> 
> You are right here in that we assume pageFirst is never larger than
> nPages but that is not checked by poppler. Attached patch could fix
> this.

Great, that worked.

Cheers,
  Albert

> 
> Hib


More information about the poppler mailing list