This is an automated email from the ASF dual-hosted git repository.
ardovm pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO41X by this push:
new e1c63fd964 Catch invalid parameters detected by the Win32 runtime
library
e1c63fd964 is described below
commit e1c63fd964ba130fb7c33234fe0d975ac26c34e8
Author: Arrigo Marchiori <[email protected]>
AuthorDate: Sat Dec 6 18:58:36 2025 +0100
Catch invalid parameters detected by the Win32 runtime library
(cherry picked from commit 5251883afdfa7aed488bbefaf25b140b52763fc8)
---
main/sal/osl/w32/signal.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/main/sal/osl/w32/signal.cxx b/main/sal/osl/w32/signal.cxx
index 8b3af0970c..099560d5fa 100644
--- a/main/sal/osl/w32/signal.cxx
+++ b/main/sal/osl/w32/signal.cxx
@@ -53,6 +53,14 @@ static oslSignalHandlerImpl* SignalList;
static long WINAPI SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP);
+static _invalid_parameter_handler pPreviousInvalidParameterHandler = NULL;
+static void InvalidParameterHandlerFunction(
+ const wchar_t* expression,
+ const wchar_t* function,
+ const wchar_t* file,
+ unsigned int line,
+ uintptr_t pReserved );
+
static sal_Bool InitSignal(void)
{
HMODULE hFaultRep;
@@ -60,6 +68,10 @@ static sal_Bool InitSignal(void)
SignalListMutex = osl_createMutex();
SetUnhandledExceptionFilter(SignalHandlerFunction);
+ if ( pPreviousInvalidParameterHandler == NULL )
+ {
+ pPreviousInvalidParameterHandler =
_set_invalid_parameter_handler( InvalidParameterHandlerFunction );
+ }
hFaultRep = LoadLibrary( "faultrep.dll" );
if ( hFaultRep )
@@ -80,6 +92,11 @@ static sal_Bool DeInitSignal(void)
{
SetUnhandledExceptionFilter(NULL);
+ if ( pPreviousInvalidParameterHandler )
+ {
+ _set_invalid_parameter_handler(
pPreviousInvalidParameterHandler );
+ pPreviousInvalidParameterHandler = NULL;
+ }
osl_destroyMutex(SignalListMutex);
return sal_False;
@@ -322,6 +339,36 @@ static long WINAPI
SignalHandlerFunction(LPEXCEPTION_POINTERS lpEP)
return (EXCEPTION_CONTINUE_EXECUTION);
}
+static void InvalidParameterHandlerFunction(
+ const wchar_t* expression,
+ const wchar_t* function,
+ const wchar_t* file,
+ unsigned int line,
+ uintptr_t pReserved )
+{
+ oslSignalInfo Info;
+
+ fwprintf(stderr, L"Invalid parameter detected in function %s.\n"
+ L"File: %s\n"
+ L"Line: %u\n"
+ L"Expression: %s\n"
+ L"pReserved: %p\n", function, file, line, expression,
pReserved);
+
+ Info.Signal = osl_Signal_AccessViolation;
+ Info.UserSignal = 0;
+ Info.UserData = NULL;
+ if ( ReportCrash( NULL ) || IsWin95A() )
+ {
+ CallSignalHandler(&Info);
+ abort(); // Equivalent of osl_Signal_ActAbortApp
+ } else {
+ // Equivalent of osl_Signal_ActKillApp
+ SetErrorMode(SEM_NOGPFAULTERRORBOX);
+ exit(255);
+ }
+ // We will never reach this point
+}
+
/*****************************************************************************/
/* osl_addSignalHandler */
/*****************************************************************************/