mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 15:43:44 +00:00
Coverity fixes.
The Boost UUID random generator can throw an entropy error in the KIID object constructor which leaves the UUID generator in an undefined state. This is treated as a fatal error and KiCad is closed. The likelihood of this occurring is low but at least now it is properly handled and cannot result in UUID clashes. Reports 305311, 305372, 305492, 314743, 314754, 314757, 316277.
This commit is contained in:
parent
7dc2ca93cd
commit
664c301cc7
@ -30,6 +30,13 @@
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
#include <boost/uuid/entropy_error.hpp>
|
||||
#endif
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
|
||||
// Create only once, as seeding is *very* expensive
|
||||
static boost::uuids::random_generator randomGenerator;
|
||||
|
||||
@ -40,6 +47,7 @@ static boost::uuids::nil_generator nilGenerator;
|
||||
// Global nil reference
|
||||
KIID niluuid( 0 );
|
||||
|
||||
|
||||
// For static initialization
|
||||
KIID& NilUuid()
|
||||
{
|
||||
@ -48,8 +56,25 @@ KIID& NilUuid()
|
||||
}
|
||||
|
||||
|
||||
KIID::KIID() : m_uuid( randomGenerator() ), m_cached_timestamp( 0 )
|
||||
KIID::KIID()
|
||||
{
|
||||
m_cached_timestamp = 0;
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
try
|
||||
{
|
||||
#endif
|
||||
|
||||
m_uuid = randomGenerator();
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
}
|
||||
catch( const boost::uuids::entropy_error& e )
|
||||
{
|
||||
wxLogFatalError( "A Boost UUID entropy exception was thrown in %s:%s.",
|
||||
__FILE__, __FUNCTION__ );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +112,21 @@ KIID::KIID( const wxString& aString ) : m_uuid(), m_cached_timestamp( 0 )
|
||||
{
|
||||
// Failed to parse string representation; best we can do is assign a new
|
||||
// random one.
|
||||
m_uuid = randomGenerator();
|
||||
#if BOOST_VERSION >= 106700
|
||||
try
|
||||
{
|
||||
#endif
|
||||
|
||||
m_uuid = randomGenerator();
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
}
|
||||
catch( const boost::uuids::entropy_error& e )
|
||||
{
|
||||
wxLogFatalError( "A Boost UUID entropy exception was thrown in %s:%s.",
|
||||
__FILE__, __FUNCTION__ );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,4 +250,4 @@ wxString KIID_PATH::AsString() const
|
||||
path += '/' + pathStep.AsString();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user