Kaydet (Commit) a5847cff authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1297235 Uncaught exception

Change-Id: I6b135f6d47352c1fbb729788848913402b7bb742
üst a1a3e047
...@@ -294,85 +294,94 @@ public: ...@@ -294,85 +294,94 @@ public:
} }
SAL_IMPLEMENT_MAIN() { SAL_IMPLEMENT_MAIN()
{
bool ok = false;
try
{
#ifdef WNT #ifdef WNT
//Disable Dr-Watson in order to crash simply without popup dialogs under //Disable Dr-Watson in order to crash simply without popup dialogs under
//windows //windows
DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX); DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode); SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode);
#ifdef _DEBUG // These functions are present only in the debgging runtime #ifdef _DEBUG // These functions are present only in the debgging runtime
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif #endif
#endif #endif
std::vector<CppUnit::Protector *> protectors; std::vector<CppUnit::Protector *> protectors;
CppUnit::TestResult result; CppUnit::TestResult result;
std::string args; std::string args;
std::string testlib; std::string testlib;
sal_uInt32 index = 0; sal_uInt32 index = 0;
while (index < rtl_getAppCommandArgCount()) while (index < rtl_getAppCommandArgCount())
{
rtl::OUString arg = getArgument(index);
if ( arg != "--protector" )
{ {
if (testlib.empty()) rtl::OUString arg = getArgument(index);
if ( arg != "--protector" )
{ {
testlib = rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr(); if (testlib.empty())
args += testlib; {
testlib = rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr();
args += testlib;
}
else
{
args += ' ';
args += rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr();
}
++index;
continue;
} }
else if (rtl_getAppCommandArgCount() - index < 3) {
{ usageFailure();
args += ' ';
args += rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr();
} }
++index; rtl::OUString lib(getArgument(index + 1));
continue; rtl::OUString sym(getArgument(index + 2));
}
if (rtl_getAppCommandArgCount() - index < 3) {
usageFailure();
}
rtl::OUString lib(getArgument(index + 1));
rtl::OUString sym(getArgument(index + 2));
#ifndef DISABLE_DYNLOADING #ifndef DISABLE_DYNLOADING
osl::Module mod(lib, SAL_LOADMODULE_GLOBAL); osl::Module mod(lib, SAL_LOADMODULE_GLOBAL);
oslGenericFunction fn = mod.getFunctionSymbol(sym); oslGenericFunction fn = mod.getFunctionSymbol(sym);
mod.release(); mod.release();
#else #else
oslGenericFunction fn = 0; oslGenericFunction fn = 0;
if (sym == "unoexceptionprotector") if (sym == "unoexceptionprotector")
fn = (oslGenericFunction) unoexceptionprotector; fn = (oslGenericFunction) unoexceptionprotector;
else if (sym == "unobootstrapprotector") else if (sym == "unobootstrapprotector")
fn = (oslGenericFunction) unobootstrapprotector; fn = (oslGenericFunction) unobootstrapprotector;
else if (sym == "vclbootstrapprotector") else if (sym == "vclbootstrapprotector")
fn = (oslGenericFunction) vclbootstrapprotector; fn = (oslGenericFunction) vclbootstrapprotector;
else else
{ {
std::cerr std::cerr
<< "Only unoexceptionprotector or unobootstrapprotector protectors allowed" << "Only unoexceptionprotector or unobootstrapprotector protectors allowed"
<< std::endl; << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
#endif #endif
CppUnit::Protector *protector = fn == 0 CppUnit::Protector *protector = fn == 0
? 0 ? 0
: (*reinterpret_cast< cppunittester::ProtectorFactory * >(fn))(); : (*reinterpret_cast< cppunittester::ProtectorFactory * >(fn))();
if (protector == 0) { if (protector == 0) {
std::cerr std::cerr
<< "Failure instantiating protector \"" << convertLazy(lib) << "Failure instantiating protector \"" << convertLazy(lib)
<< "\", \"" << convertLazy(sym) << '"' << std::endl; << "\", \"" << convertLazy(sym) << '"' << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
}
protectors.push_back(protector);
index+=3;
} }
protectors.push_back(protector);
index+=3;
}
ProtectedFixtureFunctor tests(testlib, args, protectors, result); ProtectedFixtureFunctor tests(testlib, args, protectors, result);
bool ok = tests.run(); ok = tests.run();
}
catch (const std::exception& e)
{
SAL_WARN("vcl.app", "Fatal exception: " << e.what());
}
return ok ? EXIT_SUCCESS : EXIT_FAILURE; return ok ? EXIT_SUCCESS : EXIT_FAILURE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment