Detect some endless loops
diff --git a/main/filter/source/msfilter/msdffimp.cxx b/main/filter/source/msfilter/msdffimp.cxx
index 4ae3526..398b0fc 100644
--- a/main/filter/source/msfilter/msdffimp.cxx
+++ b/main/filter/source/msfilter/msdffimp.cxx
@@ -3025,12 +3025,18 @@
 		pCList = (DffRecordList*)this;
 		while ( pCList->pNext )
 			pCList = pCList->pNext;
+        sal_Size nLastPosition;
 		while ( ( rIn.GetError() == 0 ) && ( ( rIn.Tell() + 8 ) <=  nStOfs ) )
 		{
+            nLastPosition = rIn.Tell();
 			if ( pCList->nCount == DFF_RECORD_MANAGER_BUF_SIZE )
 				pCList = new DffRecordList( pCList );
 			rIn >> pCList->mHd[ pCList->nCount ];
 			pCList->mHd[ pCList->nCount++ ].SeekToEndOfRecord( rIn );
+            if (rIn.Tell() == nLastPosition) {
+                // We are inside an endless loop
+                break;
+            }
 		}
 		rIn.Seek( nOldPos );
 	}
diff --git a/main/filter/source/msfilter/svdfppt.cxx b/main/filter/source/msfilter/svdfppt.cxx
index b0571fa..86fbab9 100644
--- a/main/filter/source/msfilter/svdfppt.cxx
+++ b/main/filter/source/msfilter/svdfppt.cxx
@@ -2954,8 +2954,10 @@
 
 		rSlidePersist.pHeaderFooterEntry = new HeaderFooterEntry( pMasterPersist );
 		ProcessData aProcessData( rSlidePersist, (SdPage*)pRet );
+        sal_Size nLastPosition;
 		while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
 		{
+            nLastPosition = rStCtrl.Tell();
 			DffRecordHeader aHd;
 			rStCtrl >> aHd;
 			switch ( aHd.nRecType )
@@ -3062,9 +3064,11 @@
 									DffRecordHeader aShapeHd;
 									if ( SeekToRec( rStCtrl, DFF_msofbtSpContainer, aEscherObjListHd.GetRecEndFilePos(), &aShapeHd ) )
 									{
+                                        sal_Size nShapeLastPosition;
 										aShapeHd.SeekToEndOfRecord( rStCtrl );
 										while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) )
 										{
+                                            nShapeLastPosition = rStCtrl.Tell();
 											rStCtrl >> aShapeHd;
 											if ( ( aShapeHd.nRecType == DFF_msofbtSpContainer ) || ( aShapeHd.nRecType == DFF_msofbtSpgrContainer ) )
 											{
@@ -3085,6 +3089,10 @@
 												}
 											}
 											aShapeHd.SeekToEndOfRecord( rStCtrl );
+                                            if (rStCtrl.Tell() == nShapeLastPosition) {
+                                                // We are inside an endless loop
+                                                break;
+                                            }
 										}
 									}
 								}
@@ -3137,6 +3145,10 @@
 				break;
 			}
 			aHd.SeekToEndOfRecord( rStCtrl );
+            if (rStCtrl.Tell() == nLastPosition) {
+                // We are inside an endless loop
+                break;
+            }
 		}
 		if ( rSlidePersist.pSolverContainer )
             SolveSolver( *rSlidePersist.pSolverContainer );