mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-10 03:54:54 -06:00
Core: CParser overflow checks FP Win32 #541
git-svn-id: svn://ultimatepp.org/upp/trunk@6469 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d52d87d669
commit
140aeb8b79
1 changed files with 11 additions and 6 deletions
|
|
@ -236,10 +236,11 @@ uint64 CParser::ReadNumber64(int base) throw(Error)
|
|||
double CParser::ReadDouble() throw(Error)
|
||||
{
|
||||
LTIMING("ReadDouble");
|
||||
#ifdef PLATFORM_POSIX
|
||||
#ifdef FE_OVERFLOW
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
#ifdef PLARFORM_WIN32
|
||||
_clearfp();
|
||||
#endif
|
||||
#if defined(PLATFORM_POSIX) && defined(FE_OVERFLOW)
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
#endif
|
||||
int sign = Sgn();
|
||||
if(!IsDigit(*term))
|
||||
|
|
@ -258,11 +259,15 @@ double CParser::ReadDouble() throw(Error)
|
|||
n *= pow(10.0, ReadInt());
|
||||
DoSpaces();
|
||||
n = sign * n;
|
||||
#ifdef PLATFORM_POSIX
|
||||
#ifdef FE_OVERFLOW
|
||||
if(fetestexcept(FE_OVERFLOW))
|
||||
#ifdef PLATFORM_WIN32
|
||||
if(_clearfp() & SW_OVERFLOW)
|
||||
ThrowError("number is too big");
|
||||
#endif
|
||||
#if defined(PLATFORM_POSIX) && defined(FE_OVERFLOW)
|
||||
if(fetestexcept(FE_OVERFLOW)) {
|
||||
ThrowError("number is too big");
|
||||
feclearexcept(FE_OVERFLOW);
|
||||
}
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue