code analysis - CA2202 Do not dispose objects multiple times - many times in managed c++ -


we getting many instances of: "ca2202 not dispose objects multiple times" in managed c++ code analysis on.

to me seems mistake in code analysis, may missing something.

ca2202 not dispose objects multiple times object 'gcnew configurationdataassembler()' can disposed more once in method 'dataassembler::createconfiguration(guid, int^, int^, objectreference^, objectreference^, objectreference^, list^%, plresult^%)'. avoid generating system.objectdisposedexception should not call dispose more 1 time on object.: lines: 935, 938 pl dataassembler.cpp 935

the 2 lines mentions "return nullptr" , "return configdto"

i have marked lines comments // here, // , here

here function

  //---------------------------------------------------------------------------------------------------------   // idataassembler   ivara::pl::data::uidata::control::mclbconfig^ dataassembler::createconfiguration( system::guid activitykey, int subscriptionid, int controlid, objectreference^ prootobjref, objectreference^ pselectedobjref, objectreference^ powningobjref, [out] list<ivara::pl::data::uidata::control::configurationlistitem^>^% configlist, [out] plresult^% result )   {      try      {         autostopwatch stopwatch( __function__, logcategories::remotingtimings );         threadtoactivity ctta( activitykey );          result = plresult::success;          //param check         if ( subscriptionid <= 0 )         {            throw gcnew ivara::pl::exceptions::ivaraargumentexception( _t( "invalid configurationid" ), _t( "configurationid" ) );         }          //fetch config         userconfigurationor oruserconfig( subscriptionid );           if ( !oruserconfig.isset() )         {            result = gcnew plresult( plresult::estatus::relatedobjectnotfound, string::format( _t( "the user configuration {0} not found" ), subscriptionid ) );            return nullptr;         }          userconfiguration* puserconfig = oruserconfig.qryobjptr();         if ( puserconfig == null )         {            result = gcnew plresult( plresult::estatus::relatedobjectnotfound, string::format( _t( "the user configuration {0} not fetched, though isset returns true" ), subscriptionid ) );            return nullptr;         }         //create assembler          configurationdataassembler assembler;         assembler.initialize( controlid, prootobjref, pselectedobjref, powningobjref, result );         if ( result != plresult::success )         {            return nullptr; // here         }         ivara::pl::data::uidata::control::mclbconfig^ configdto = assembler.assembleconfigurationdto( puserconfig, configlist /*out param*/, nullptr );         return configdto; // , here       }      catch ( otbaseexception& unmanagedexception )      {         throw fatalexceptionpolicy::handleunmanagedexception( &unmanagedexception, __funcdname__, __file__, __line__ );      }      catch ( exception^ managedexception )      {         throw fatalexceptionpolicy::handlemanagedexception( managedexception, __funcdname__, __file__, __line__ );      }   } 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -