[typos fixed and code re-wrapped in quote]

Hello Georg, hello all,
> On 10 May 2018 at 16:14 Georg Funk <georgf...@hotmail.de> wrote:
> 
> 
> Dear developers,
> 
> I'm getting a segmentation fault in the following code snippet when
> resolving IsReference()):
> 
> if (objectVector.GetObject(currentReference)->IsReference()) {
>     currentReference = objectVector
>                      .GetObject(currentReference)->GetReference();
> }
> else {}
> 
> objectVector is a global variable here and currentReference holds a
> PdfReference to look up.

the method PdfVecObjects::GetObject() (your objectVector is of type
PdfVecObjects, right?) can return NULL (nullptr from C++11), this
means that the the reference passed (your currentReference) could
not be resolved (no object with those numbers was found in the vector).
Then IsReference() would be called with NULL this (undefined behaviour
AFAIK).

> 
> Error message from gdb:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x000055ba2342486e in PoDoFo::PdfVariant::DelayedLoad (this=0x0) at
> /usr/local/include/podofo/base/PdfVariant.h:545
> 545       if( !m_bDelayedLoadDone)
> 

There it is, the "this" implicit argument with NULL value,
through some extra call(s).
> Have you any idea for me?

The return value of PdfVecObjects::GetObject() should be 
stored in a pointer variable which is then checked for
NULL (nullptr preferably for C++11 or newer) and used only
if it isn't equal to that.
> 
> Thank you!
> 

You're welcome.
> Best regards,
> Georg

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