Примеры ошибок, обнаруженных с помощью диагностики V509
V509. Exceptions raised inside noexcept functions must be wrapped in a try..catch block.
OGRE
V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. OgreMain ogrearchivemanager.cpp 124
#ifndef OGRE_EXCEPT
#define OGRE_EXCEPT(num, desc, src) \
throw Ogre::ExceptionFactory::create( \
Ogre::ExceptionCodeType<num>(), desc, \
src, __FILE__, __LINE__ );
#endif
ArchiveManager::~ArchiveManager()
{
// Unload & delete resources in turn
for( ArchiveMap::iterator it = mArchives.begin();
it != mArchives.end(); ++it )
{
Archive* arch = it->second;
// Unload
arch->unload();
// Find factory to destroy
ArchiveFactoryMap::iterator fit =
mArchFactories.find(arch->getType());
if (fit == mArchFactories.end())
{
// Factory not found
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Cannot find an archive factory "
"to deal with archive of type " +
arch->getType(),
"ArchiveManager::~ArchiveManager");
}
fit->second->destroyInstance(arch);
}
// Empty the list
mArchives.clear();
}
TortoiseSVN
V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. cachefileoutbuffer.cpp 52
CCacheFileOutBuffer::~CCacheFileOutBuffer()
{
if (IsOpen())
{
streamOffsets.push_back (GetFileSize());
size_t lastOffset = streamOffsets[0];
for (size_t i = 1,
count = streamOffsets.size();
i < count; ++i)
{
size_t offset = streamOffsets[i];
size_t size = offset - lastOffset;
if (size >= (DWORD)(-1))
throw CStreamException("stream too large");
Add ((DWORD)size);
lastOffset = offset;
}
Add ((DWORD)(streamOffsets.size()-1));
}
}
NetXMS
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. nodeperfview.cpp 109
CNodePerfView::~CNodePerfView()
{
WorkerTask *pTask;
while((pTask = (WorkerTask *)m_workerQueue.Get()) != NULL)
delete pTask;
m_workerQueue.Put(new WorkerTask(NULL, TASK_SHUTDOWN));
ThreadJoin(m_hWorkerThread);
safe_free(m_pGraphList);
}
Chromium
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. prerender_contents.cc 382
PrerenderContents::~PrerenderContents() {
....
for (....)
{
content::RenderProcessHost* host =
host_iterator.GetCurrentValue();
host->Send(
new PrerenderMsg_OnPrerenderRemoveAliases(alias_urls_));
}
....
}
Similar errors can be found in some other places:
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. sync_task_manager.cc 40
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. proxy_webidbdatabase_impl.cc 42
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. proxy_webidbcursor_impl.cc 38
- And 12 additional diagnostic messages.
Geant4 software
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. _G4FR-archive g4thitscollection.hh 161
template <class T> G4THitsCollection<T>::~G4THitsCollection()
{
if (!anHCAllocator_G4MT_TLS_) anHCAllocator_G4MT_TLS_ =
new G4Allocator<G4HitsCollection>;
std::vector<T*> * theHitsCollection =
(std::vector<T*>*)theCollection;
//theHitsCollection->clearAndDestroy();
for(size_t i=0;i<theHitsCollection->size();i++)
{ delete (*theHitsCollection)[i]; }
theHitsCollection->clear();
delete theHitsCollection;
}
Similar errors can be found in some other places:
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. _G4digits_hits-archive g4hcofthisevent.cc 49
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. _G4digits_hits-archive g4dcofthisevent.cc 49
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. _G4digits_hits-archive g4tdigicollection.hh 165
- And 11 additional diagnostic messages.
Protocol Buffers
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. command_line_interface.cc 479
CommandLineInterface::MemoryOutputStream::~MemoryOutputStream()
{
....
*map_slot = new string;
....
}
Source Engine SDK
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. Client (HL2) particles_new.cpp 92
CNewParticleEffect::~CNewParticleEffect(void)
{
....
KeyValues *msg = new KeyValues( "ParticleSystem_Destroy" );
....
}
Source Engine SDK
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. Client (HL2) toolframework_client.cpp 222
CRecordEffectOwner::~CRecordEffectOwner()
{
if ( m_bToolsEnabled )
{
KeyValues *msg = new KeyValues( "EffectsOwner" );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
Data Distribution Service
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. sedp.cpp 2456
Sedp::Task::~Task()
{
putq(new Msg(Msg::MSG_STOP, DCPS::GRACEFUL_DISCONNECT, 0));
wait();
}
Similar errors can be found in some other places:
- V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. sync.cpp 19
- V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. sync.cpp 93
- V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. sync.cpp 158
FlightGear
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. renderer.cxx 437
FGRenderer::~FGRenderer()
{
....
getViewer()->setSceneData(new osg::Group);
....
}
TortoiseGit
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. preservechdir.cpp 43
PreserveChdir::~PreserveChdir()
{
if (originalCurrentDirectory)
{
DWORD len = GetCurrentDirectory(0, NULL);
TCHAR * currentDirectory = new TCHAR[len];
....
}
TortoiseSVN
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. preservechdir.cpp 43
PreserveChdir::~PreserveChdir()
{
....
std::unique_ptr<TCHAR[]> currentDirectory(new TCHAR[len]);
....
}
WebRTC
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. mediapipeline.h 422
~PipelineListener()
{
nsresult rv = NS_DispatchToMainThread(new
ConduitDeleteEvent(conduit_.forget()));
MOZ_ASSERT(....);
if (NS_FAILED(rv)) {
MOZ_CRASH();
}
}
Similar errors can be found in some other places:
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. mediapipeline.h 579
LibreOffice
V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. winmtf.cxx 852
WinMtfOutput::~WinMtfOutput()
{
mpGDIMetaFile->AddAction( new MetaPopAction() );
....
}
Similar errors can be found in some other places:
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. export.cxx 279
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. getfilenamewrapper.cxx 73
- V509 The 'new' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. e3dsceneupdater.cxx 80
- And 2 additional diagnostic messages.
LibreOffice
V509 The 'dynamic_cast<T&>' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. docbm.cxx 846
virtual ~LazyFieldmarkDeleter()
{
dynamic_cast<Fieldmark&>
(*m_pFieldmark.get()).ReleaseDoc(m_pDoc);
}
Similar errors can be found in some other places:
- V509 The 'dynamic_cast<T&>' operator should be located inside the try..catch block, as it could potentially generate an exception. Raising exception inside the destructor is illegal. ndtxt.cxx 4886
7-Zip
V509 The 'throw' operator inside the destructor should be placed within the try..catch block. Raising exception inside the destructor is illegal. consoleclose.cpp 62
CCtrlHandlerSetter::~CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
throw "SetConsoleCtrlHandler fails";
#endif
}
MuditaOS
V509 [CERT-DCL57-CPP] The noexcept function '=' calls function 'setName' which can potentially throw an exception. Consider wrapping it in a try..catch block. Device.cpp 48
struct Device
{
static constexpr auto NameBufferSize = 240;
....
void setName(const std::string &name)
{
if (name.size() > NameBufferSize)
{
throw std::runtime_error("Requested name is bigger than buffer
size");
}
strcpy(this->name.data(), name.c_str());
}
....
}
....
Devicei &Devicei::operator=(Devicei &&d) noexcept
{
setName(d.name.data());
}