[poppler] Confused about Hints::getPageObjectNum
Hib Eris
hib at hiberis.nl
Sun Jun 10 11:35:29 PDT 2012
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.
Hib
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Check-value-of-first-page-in-linearization-table.patch
Type: application/octet-stream
Size: 770 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20120610/8ff50dd3/attachment-0001.obj>
More information about the poppler
mailing list