--- src/doc/PdfPage.cpp
+++ src/doc/PdfPage.cpp
@@ -449,6 +449,7 @@
     PdfArray::iterator it;
     PdfObject*         pObj   = this->GetAnnotationsArray( false );
     bool               bFound = false;
+    PdfReference       refCpy = ref; // Ref will be invalidated after erase()!    
 
     // delete the annotation from the array
 
@@ -479,15 +480,15 @@
     }
 
     // delete any cached PdfAnnotations
-    pAnnot = m_mapAnnotations[ref];
+    pAnnot = m_mapAnnotations[refCpy];
     if( pAnnot )
     {
         delete pAnnot;
-        m_mapAnnotations.erase( ref );
+        m_mapAnnotations.erase( refCpy );
     }
 
     // delete the PdfObject in the file
-    delete this->GetObject()->GetOwner()->RemoveObject( ref );
+    delete this->GetObject()->GetOwner()->RemoveObject( refCpy );
 }
 
 // added by Petr P. Petrov 21 Febrary 2010
