From 4f34b189299950fcff70d143ce88bc5c1ed71312 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 16 Apr 2001 20:27:16 +0000 Subject: [PATCH] Fix some crash on bad parameter conditions. --- dlls/user/lstr.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/dlls/user/lstr.c b/dlls/user/lstr.c index 603f2bda48e..bd384af5442 100644 --- a/dlls/user/lstr.c +++ b/dlls/user/lstr.c @@ -15,15 +15,26 @@ #include "windef.h" #include "winbase.h" #include "winnls.h" +#include "winerror.h" #include "wine/winbase16.h" #include "wine/winuser16.h" #include "wine/unicode.h" +#include "wine/exception.h" #include "heap.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(resource); +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION || + GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + /*********************************************************************** * AnsiToOem16 (KEYBOARD.5) */ @@ -334,19 +345,24 @@ BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d ) */ LPSTR WINAPI CharLowerA(LPSTR x) { - LPSTR s; + if (!HIWORD(x)) return (LPSTR)tolower((char)(int)x); - if (HIWORD(x)) + __TRY { - s=x; + LPSTR s = x; while (*s) { *s=tolower(*s); s++; } - return x; } - else return (LPSTR)tolower((char)(int)x); + __EXCEPT(page_fault) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return NULL; + } + __ENDTRY + return x; } @@ -356,7 +372,9 @@ LPSTR WINAPI CharLowerA(LPSTR x) */ LPSTR WINAPI CharUpperA(LPSTR x) { - if (HIWORD(x)) + if (!HIWORD(x)) return (LPSTR)toupper((char)(int)x); + + __TRY { LPSTR s = x; while (*s) @@ -364,9 +382,14 @@ LPSTR WINAPI CharUpperA(LPSTR x) *s=toupper(*s); s++; } - return x; } - return (LPSTR)toupper((char)(int)x); + __EXCEPT(page_fault) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return NULL; + } + __ENDTRY + return x; } -- 2.11.4.GIT