CharUpper/Lower woes
eric pouech
eric.pouech at wanadoo.fr
Fri Apr 13 15:34:02 CDT 2001
some program (from M$, no bashing intented) is passing from parameter to
CharUpperA
in fact, it tries to test a character with bit 7 set, and end up passing
a value
like 0xFFFFFFE9 (instead of 0x0000FFE9)...
Windows correctly handles the situation (ie returns 0)
I've attached a patch protecting the conversion with a seg fault handler
may be it's a bit overkill, and testing for a HIWORD of 0xFFFF should be
faster
and as effective. Alexandre, I let you decide.
A+
--
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: lstr
ChangeLog: Fix some crash on bad pmt conditions
GenDate: 2001/04/13 20:26:35 UTC
ModifiedFiles: dlls/user/lstr.c
AddedFiles:
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/user/lstr.c,v
retrieving revision 1.10
diff -u -u -r1.10 lstr.c
--- dlls/user/lstr.c 2001/01/25 22:22:21 1.10
+++ dlls/user/lstr.c 2001/02/24 13:39:36
@@ -18,6 +18,7 @@
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/unicode.h"
+#include "wine/exception.h"
#include "heap.h"
#include "debugtools.h"
@@ -327,6 +328,11 @@
return OemToCharBuffW( s, d, strlen( s ) + 1 );
}
+static WINE_EXCEPTION_FILTER(wine_user32)
+{
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
/***********************************************************************
* CharLowerA (USER32.@)
@@ -334,39 +340,56 @@
*/
LPSTR WINAPI CharLowerA(LPSTR x)
{
- LPSTR s;
-
- if (HIWORD(x))
- {
- s=x;
- while (*s)
- {
- *s=tolower(*s);
- s++;
- }
- return x;
- }
- else return (LPSTR)tolower((char)(int)x);
+ if (HIWORD(x))
+ {
+ LPSTR s;
+
+ __TRY {
+ s = x;
+ while (*s)
+ {
+ *s=tolower(*s);
+ s++;
+ }
+ s = x;
+ }
+ __EXCEPT(wine_user32)
+ {
+ s = NULL;
+ }
+ __ENDTRY;
+ return s;
+ }
+ return (LPSTR)tolower((char)(int)x);
}
-
/***********************************************************************
* CharUpperA (USER32.@)
* FIXME: handle current locale
*/
LPSTR WINAPI CharUpperA(LPSTR x)
{
- if (HIWORD(x))
- {
- LPSTR s = x;
- while (*s)
- {
- *s=toupper(*s);
- s++;
- }
- return x;
- }
- return (LPSTR)toupper((char)(int)x);
+ if (HIWORD(x))
+ {
+ LPSTR s;
+
+ __TRY {
+ s = x;
+ while (*s)
+ {
+ *s=toupper(*s);
+ s++;
+ }
+ s = x;
+ }
+ __EXCEPT(wine_user32)
+ {
+ s = NULL;
+ }
+ __ENDTRY;
+ return s;
+ }
+ return (LPSTR)toupper((char)(int)x);
}
More information about the wine-patches
mailing list