sw/source/ui/vba/vbalistformat.cxx |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 0b36794425a559355362911ec79a3bd04d5598dd
Author: Caolán McNamara <[email protected]>
Date:   Thu Jun 12 11:15:55 2014 +0100

    coverity#735985 Unchecked dynamic_cast
    
    Change-Id: I1bb293567cf6e6437d1ac1f257b25d7de1d0ac75

diff --git a/sw/source/ui/vba/vbalistformat.cxx 
b/sw/source/ui/vba/vbalistformat.cxx
index 9740758..78a498b 100644
--- a/sw/source/ui/vba/vbalistformat.cxx
+++ b/sw/source/ui/vba/vbalistformat.cxx
@@ -57,12 +57,15 @@ void SAL_CALL SwVbaListFormat::ApplyListTemplate( const 
css::uno::Reference< wor
     if( nDefaultListBehavior != 
word::WdDefaultListBehavior::wdWord8ListBehavior )
         throw uno::RuntimeException();
 
-    SwVbaListTemplate* pListTemplate = dynamic_cast< SwVbaListTemplate* >( 
ListTemplate.get() );
-
     uno::Reference< container::XEnumerationAccess > xEnumAccess( mxTextRange, 
uno::UNO_QUERY_THROW );
     uno::Reference< container::XEnumeration > xEnum = 
xEnumAccess->createEnumeration();
+    if (!xEnum->hasMoreElements())
+        return;
+
+    SwVbaListTemplate& rListTemplate = 
dynamic_cast<SwVbaListTemplate&>(*ListTemplate.get());
+
     bool isFirstElement = true;
-    while( xEnum->hasMoreElements() )
+    do
     {
         uno::Reference< beans::XPropertySet > xProps( xEnum->nextElement(), 
uno::UNO_QUERY_THROW );
         if( isFirstElement )
@@ -80,8 +83,9 @@ void SAL_CALL SwVbaListFormat::ApplyListTemplate( const 
css::uno::Reference< wor
         {
             xProps->setPropertyValue("ParaIsNumberingRestart", uno::makeAny( 
sal_False ) );
         }
-        pListTemplate->applyListTemplate( xProps );
+        rListTemplate.applyListTemplate( xProps );
     }
+    while( xEnum->hasMoreElements() );
 }
 
 void SAL_CALL SwVbaListFormat::ConvertNumbersToText(  ) throw 
(css::uno::RuntimeException, std::exception)
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to