Please accept this patch. This fixes an error where calling
PdfPage::DeleteAnnotation maintains a reference to the index provided by
the caller resulting in the deletion of multiple
array items, for example when called with (index)0, the item at 0 is
deleted once from here:
(PdfPage.cpp line 465) pObj->GetArray().erase( it )
at this point the ref passed to DeleteAnnotation is still pointing to array
index 0, but the array has shifted by 1, so now we are targeting the next
element in the array and no longer the element that was
intended on being removed.
Then we again delete the item at the 0 index here:
(PdfPage.cpp line 486) m_mapAnnotations.erase( ref );
Now both items 0 and 1 from the original array have been removed.
Now calling  PdfPage::GetNumFields we get this error: 'Error looking up
object {object number} {object generation number}'

This can be reproduced with the following:

PdfDocument doc("./test.pdf");
auto page = doc.GetPage(0)
page->DeleteAnnotation(0)
page->GetNumFields() // throw here

Here is the patch:

trunk λ svn diff src/doc/PdfPage.cpp
Index: src/doc/PdfPage.cpp
===================================================================
--- src/doc/PdfPage.cpp (revision 1928)
+++ src/doc/PdfPage.cpp (working copy)
@@ -421,7 +421,7 @@
         PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
     }

-    pItem = &(pObj->GetArray()[index]);
+    pItem = &pObj->GetArray()[index];

     if( pItem->IsDictionary() )
     {

Thank you,
Cory Mickelson

Attachment: test.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
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