From 6c2eae254f2a6005830aa697948885a084580340 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 19 Aug 2005 15:20:06 +0000 Subject: [PATCH] Protect GlobalAddAtomA string handling by exception handler (for broken programs). --- dlls/kernel/atom.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/dlls/kernel/atom.c b/dlls/kernel/atom.c index 80a17a91466..18851815034 100644 --- a/dlls/kernel/atom.c +++ b/dlls/kernel/atom.c @@ -38,6 +38,8 @@ #include "winbase.h" #include "winerror.h" +#include "wine/exception.h" +#include "excpt.h" #include "wine/server.h" #include "wine/unicode.h" #include "kernel_private.h" @@ -48,6 +50,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(atom); #define MAX_ATOM_LEN 255 +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + static struct atom_table* get_local_table(DWORD entries) { static struct atom_table* local_table; @@ -183,7 +193,18 @@ static ATOM ATOM_AddAtomA( LPCSTR str, struct atom_table* table ) */ ATOM WINAPI GlobalAddAtomA( LPCSTR str /* [in] String to add */ ) { - return ATOM_AddAtomA( str, NULL ); + ATOM ret; + __TRY + { + ret = ATOM_AddAtomA( str, NULL ); + } + __EXCEPT(page_fault) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + __ENDTRY + return ret; } -- 2.11.4.GIT