mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix coverity issues about exceptions
There a some exceptions related to the fact that BOOST_ASSERT throws an unhandled exception, which is fait enough. This is handled by uploading a modeling file to coverity. The second batch of issues are related to the use of lexical_cast in convert.cpp. We use now a wrapper around boost::lexical_cast that does not throw but return empty strings instead. I am not sure actually of when lexical_cast could fail.
This commit is contained in:
parent
d7dfa27574
commit
2a0e4c199c
@ -9,6 +9,7 @@ SUBDIRS = cygwin
|
||||
endif
|
||||
|
||||
EXTRA_DIST = coding/Rules coding/Recommendations \
|
||||
coverity_modeling.cpp \
|
||||
FORMAT lyx.rpm.README \
|
||||
lyxserver lyx.spec.in lyx.spec \
|
||||
LyX-Mac-binary-release.sh \
|
||||
|
13
development/coverity_modeling.cpp
Normal file
13
development/coverity_modeling.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is a modeling file for coverity
|
||||
|
||||
namespace lyx {
|
||||
|
||||
// Tell coverity that this function always exits
|
||||
void doAssertWithCallstack(bool value)
|
||||
{
|
||||
if (!value) {
|
||||
__coverity_panic__();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -23,9 +23,24 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace lyx {
|
||||
namespace {
|
||||
|
||||
using boost::lexical_cast;
|
||||
// A version of lexical cast that does not throw. Useful for when we convert to string
|
||||
template<typename To, typename From>
|
||||
To lexical_cast(From const & value, To const & defaultResult = To())
|
||||
{
|
||||
try {
|
||||
return boost::lexical_cast<To>(value);
|
||||
} catch(...) {
|
||||
// Ignore all exceptions and use default.
|
||||
return defaultResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
template<>
|
||||
string convert<string>(bool b)
|
||||
|
Loading…
Reference in New Issue
Block a user