Protect GlobalAddAtomA string handling by exception handler (for

broken programs).
This commit is contained in:
Marcus Meissner 2005-08-19 15:20:06 +00:00 committed by Alexandre Julliard
parent 88bddd7ae1
commit 6c2eae254f
1 changed files with 22 additions and 1 deletions

View File

@ -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;
}