From 66c23c95db133bd616e2e35eb49e0993270add9e Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 1 Mar 2016 20:20:00 +0100 Subject: [PATCH 28/37] coverity: avoid possible null ptr deref This way dynamic_cast will throw an exception if the dynamic type does not match. --- src/libcmis/atom-object.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcmis/atom-object.cxx b/src/libcmis/atom-object.cxx index b7832d6..1eb33fa 100644 --- a/src/libcmis/atom-object.cxx +++ b/src/libcmis/atom-object.cxx @@ -106,13 +106,13 @@ libcmis::ObjectPtr AtomObject::updateProperties( const PropertyPtrMap& propertie libcmis::ObjectPtr object; if ( getBaseType( ) == "cmis:document" ) { - AtomDocument* thisDoc = dynamic_cast< AtomDocument* >( this ); - object.reset( new AtomDocument( *thisDoc ) ); + const AtomDocument& thisDoc = dynamic_cast< const AtomDocument& >( *this ); + object.reset( new AtomDocument( thisDoc ) ); } else if ( getBaseType( ) == "cmis:folder" ) { - AtomFolder* thisFolder = dynamic_cast< AtomFolder* >( this ); - object.reset( new AtomFolder( *thisFolder ) ); + const AtomFolder& thisFolder = dynamic_cast< const AtomFolder& >( *this ); + object.reset( new AtomFolder( thisFolder ) ); } return object; } -- 2.5.0