Hello zyx, hello Francesco, hello all,

this is a resend of the email content (with main headers) below.
I'm sorry that e-mail didn't reach (all of) you originally.

Best regards, mabri

---------- Original Message ----------
From: Matthew Brincke <ma...@mailbox.org>
To: Francesco Pretto <cez...@gmail.com>
Cc: Dominik Seichter via Podofo-users <podofo-users@lists.sourceforge.net>
Date: 25 February 2018 at 23:59
Subject: Re: [Podofo-users] [PATCH 05/13] PdfPagesTree::InsertPage: Fix 
"atIndex" is really a 0-based index
Hello Francesco, hello all,
> On 23 February 2018 at 22:25 Francesco Pretto <cez...@gmail.com> wrote:
> 
> 
> On 23 February 2018 at 19:27, Francesco Pretto <cez...@gmail.com> wrote:
> > I tested it with following code:
> >
>

I'm sorry I couldn't make it yesterday, I was too tired because I couldn't
sleep well for long enough that night. Now I've done the review and test:
patch looks good, compiles without warnings, avoids a crash with your test
code below (with a minor change, please see there), so I've accepted and
committed it in svn r1898: https://sourceforge.net/p/podofo/code/1898/

> Oops...a missing fragment in the test code. Here it again complete:
> 
>     PdfMemDocument document;
>     PdfRect rect;
> 
>     auto pageA = document.InsertPage(rect, 0);
>     auto pageB = document.InsertPage(rect, 0);
>     auto pageC = document.InsertPage(rect, 2);
> 
>     // PageNumber is 1-based index
>     assert(pageA->GetPageNumber() == 2);
>     assert(pageB->GetPageNumber() == 1);
>     assert(pageC->GetPageNumber() == 3);
> 
>     // Insert ouf of bounds
>     auto page = document.InsertPage(rect, -1);
>     assert(page->GetPageNumber() == 1);
>     int pageCount = document.GetPageCount();
This definition I've changed to "unsigned int" because ... 
>     page = document.InsertPage(rect, pageCount + 1);
>     assert(page->GetPageNumber() == pageCount + 1);
for this I received a warning from GCC about unsigned/signed comparison.
> 
>     // Insert in the middle
>     page = document.InsertPage(rect, 2);
>     assert(page->GetPageNumber() == 3);

Without the patch, this had GCC Adress Sanitizer report a SEGV crash
by illegal memory access (at address 0, so a null pointer dereference),
with the patch all went well. Thanks for the patch and the test code!

Best regards, mabri

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to