On Sun, Aug 14, 2005 at 10:27:20PM +0200, Felix Nawothnig wrote:
Marcus Meissner wrote:
Yes, but please don't use the IsBad* functions, use a proper exception handler.
Next try, is this what you imagined.
The reason for using an exception handler is thread safety - to achieve that you have to put it around the ATOM_AddAtomA call.
Next try...
Ciao, Marcus
Changelog: Wrap GlobalAddAtomA() internal call with exception handler.
Index: dlls/kernel/atom.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/atom.c,v retrieving revision 1.8 diff -u -r1.8 atom.c --- dlls/kernel/atom.c 10 May 2005 15:15:50 -0000 1.8 +++ dlls/kernel/atom.c 15 Aug 2005 05:35:29 -0000 @@ -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 @@
#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,14 @@ */ ATOM WINAPI GlobalAddAtomA( LPCSTR str /* [in] String to add */ ) { - return ATOM_AddAtomA( str, NULL ); + __TRY { + return ATOM_AddAtomA( str, NULL ); + } + __EXCEPT(page_fault) { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + __ENDTRY }