Module: wine Branch: master Commit: 4dba956ea696592ac446b4c0042f935bf608cabf URL: http://source.winehq.org/git/wine.git/?a=commit;h=4dba956ea696592ac446b4c004...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Nov 26 14:57:24 2010 +0100
msvcrt: Add parameter checking in _controlfp_s.
---
dlls/msvcrt/math.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 4a3f65e..b6423e9 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -909,12 +909,7 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask) */ unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask) { -#ifdef __i386__ return _control87( newval, mask & ~MSVCRT__EM_DENORMAL ); -#else - FIXME(":Not Implemented!\n"); - return 0; -#endif }
/********************************************************************* @@ -922,21 +917,16 @@ unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask) */ int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask) { -#ifdef __i386__ - unsigned int flags; - - FIXME("(%p %u %u) semi-stub\n", cur, newval, mask); - - flags = _control87( newval, mask & ~MSVCRT__EM_DENORMAL ); + static const unsigned int all_flags = (MSVCRT__MCW_EM | MSVCRT__MCW_IC | MSVCRT__MCW_RC | + MSVCRT__MCW_PC | MSVCRT__MCW_DN);
- if(cur) - *cur = flags; - - return 0; -#else - FIXME(":Not Implemented!\n"); + if (!MSVCRT_CHECK_PMT(cur != NULL) || !MSVCRT_CHECK_PMT( !(mask & ~all_flags) )) + { + *MSVCRT__errno() = MSVCRT_EINVAL; + return MSVCRT_EINVAL; + } + *cur = _controlfp( newval, mask ); return 0; -#endif }
/*********************************************************************