From bb82f5c1e946333781779cd21ab64aa19f02cd85 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Mon, 18 Feb 2013 02:12:13 -0600 Subject: coverity#982443 Explicitt null dereferenced Change-Id: I470c34c38eda673e6663b23cdb28ea4be0bef914 Reviewed-on: https://gerrit.libreoffice.org/2218 Reviewed-by: Norbert Thiebaud Tested-by: Norbert Thiebaud --- basctl/source/basicide/bastype3.cxx | 64 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'basctl') diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx index db15a6a6787e..c734642ddc26 100644 --- a/basctl/source/basicide/bastype3.cxx +++ b/basctl/source/basicide/bastype3.cxx @@ -208,49 +208,45 @@ SbxVariable* TreeListBox::FindVariable( SvTreeListEntry* pEntry ) switch ( pBE->GetType() ) { - case OBJ_TYPE_LIBRARY: - { - if (BasicManager* pBasMgr = aDocument.getBasicManager()) - pVar = pBasMgr->GetLib( aName ); - } + case OBJ_TYPE_LIBRARY: + if (BasicManager* pBasMgr = aDocument.getBasicManager()) + pVar = pBasMgr->GetLib( aName ); break; - case OBJ_TYPE_MODULE: + case OBJ_TYPE_MODULE: + DBG_ASSERT(dynamic_cast(pVar), "FindVariable: invalid Basic"); + if(!pVar) { - DBG_ASSERT(dynamic_cast(pVar), "FindVariable: invalid Basic"); - // extract the module name from the string like "Sheet1 (Example1)" - if( bDocumentObjects ) - { - sal_uInt16 nIndex = 0; - aName = aName.GetToken( 0, ' ', nIndex ); - } - pVar = static_cast(pVar)->FindModule( aName ); + break; } - break; - case OBJ_TYPE_METHOD: + // extract the module name from the string like "Sheet1 (Example1)" + if( bDocumentObjects ) { - DBG_ASSERT(dynamic_cast(pVar), "FindVariable: invalid modul/object"); - pVar = static_cast(pVar)->GetMethods()->Find(aName, SbxCLASS_METHOD); + sal_uInt16 nIndex = 0; + aName = aName.GetToken( 0, ' ', nIndex ); } + pVar = static_cast(pVar)->FindModule( aName ); break; - case OBJ_TYPE_DIALOG: + case OBJ_TYPE_METHOD: + DBG_ASSERT(dynamic_cast(pVar), "FindVariable: invalid modul/object"); + if(!pVar) { - // sbx dialogs removed + break; } + pVar = static_cast(pVar)->GetMethods()->Find(aName, SbxCLASS_METHOD); break; - case OBJ_TYPE_DOCUMENT_OBJECTS: - bDocumentObjects = true; - case OBJ_TYPE_USERFORMS: - case OBJ_TYPE_NORMAL_MODULES: - case OBJ_TYPE_CLASS_MODULES: - { - // skip, to find the child entry. - continue; - } - default: - { - OSL_FAIL( "FindVariable: Unbekannter Typ!" ); - pVar = 0; - } + case OBJ_TYPE_DIALOG: + // sbx dialogs removed + break; + case OBJ_TYPE_DOCUMENT_OBJECTS: + bDocumentObjects = true; + case OBJ_TYPE_USERFORMS: + case OBJ_TYPE_NORMAL_MODULES: + case OBJ_TYPE_CLASS_MODULES: + // skip, to find the child entry. + continue; + default: + OSL_FAIL( "FindVariable: Unbekannter Typ!" ); + pVar = 0; break; } if ( !pVar ) -- cgit