summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-09-05 08:35:07 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-09-10 10:59:15 +0000
commitb87abdf142d23952f83bae0291854e71bf5534da (patch)
tree7b31db9224eac455df8678874fc9aba52dd2b5f8 /sal
parentf80d0c180c7e98caf211059f54873001f9e0a64e (diff)
fdo#38913: Prevent invalid parameter handler crashes
It appears that on Windows at least some jvm.dll versions can cause calls to _fileno(NULL), which leads to a call of the invalid parameter handler (see <http://msdn.microsoft.com/en-us/library/ksazx244%28v=vs.80%29.aspx> "Parameter Validation: Visual Studio 2005"). The default handler causes the application to crash, so install a "harmless" one instead. Change-Id: Id6a3ffb63f70b0c65546bc933e994c8dbf35203c (cherry picked from commit a82e532ce006c54b2740de74d1da5d11307da7c1) Reviewed-on: https://gerrit.libreoffice.org/564 Reviewed-by: Michael Meeks <michael.meeks@suse.com> Tested-by: Michael Meeks <michael.meeks@suse.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/w32/salinit.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sal/osl/w32/salinit.cxx b/sal/osl/w32/salinit.cxx
index 5390c9285f16..aaa5a5b321c3 100644
--- a/sal/osl/w32/salinit.cxx
+++ b/sal/osl/w32/salinit.cxx
@@ -26,6 +26,10 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <iostream>
+#include <stdlib.h>
#include "system.h"
#include <osl/process.h>
@@ -35,6 +39,23 @@
extern "C" {
#endif
+// _set_invalid_parameter_handler appears unavailable with MinGW:
+#if defined _MSC_VER
+namespace {
+
+extern "C" void invalidParameterHandler(
+ wchar_t const * expression, wchar_t const * function, wchar_t const * file,
+ unsigned int line, SAL_UNUSED_PARAMETER uintptr_t)
+{
+ std::wcerr
+ << L"Invalid parameter in \"" << (expression ? expression : L"???")
+ << L"\" (" << (function ? function : L"???") << ") at "
+ << (file ? file : L"???") << L':' << line << std::endl;
+}
+
+}
+#endif
+
// Prototypes for initialization and deinitialization of SAL library
SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv)
@@ -86,6 +107,14 @@ SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv)
// How to handle a very unlikely error ???
}
+#if defined _MSC_VER // appears unavailable with MinGW
+ // It appears that at least some jvm.dll versions can cause calls to
+ // _fileno(NULL), which leads to a call of the invalid parameter handler,
+ // and the default handler causes the application to crash, so install a
+ // "harmless" one (cf. fdo#38913):
+ _set_invalid_parameter_handler(&invalidParameterHandler);
+#endif
+
osl_setCommandArgs(argc, argv);
}