diff options
author | Andrea Faulds <ajf@ajf.me> | 2014-12-13 18:38:15 +0000 |
---|---|---|
committer | Andrea Faulds <ajf@ajf.me> | 2014-12-13 18:38:15 +0000 |
commit | 0ea0b591d79ae0ee18d33533a5c701330836ff6b (patch) | |
tree | 8612c30a23ce7ed8ed0d376f571597ddc7c5d171 /Zend/zend_operators.h | |
parent | de0afce55b085f9983f9d49ced5244f748b30750 (diff) | |
parent | d5afeef24742be2c2f6b7a8b0932301eca0f9968 (diff) | |
download | php-git-0ea0b591d79ae0ee18d33533a5c701330836ff6b.tar.gz |
Merge branch 'zppFailOnOverflow'
* zppFailOnOverflow:
Fix MySQLi tests
Fixed gd test
Refactor ZEND_LONG_MAX/MIN checks into ZEND_DOUBLE_FITS_LONG()
Fixed copy-and-paste error
Fix more 32-bit tests
Skip buncha tests on 32-bit
skip simplexml
skip posix 32-bit
skip tests on 32-bit
Fixes simplexml test
Fixes posix tests
Fixes iconv tests
Marked tests as 32-bit
Fixed more 32-bit tests
Fixed some 32-bit tests
Mark said ext/date tests as 32-bit only
Fixed ext/date tests broken by zpp error on overflow
Fixed broken tests
Make zpp fail if NaN passed for int, or out-of-range float for non-capping int
Conflicts:
ext/date/tests/getdate_variation7.phpt
ext/date/tests/localtime_variation3.phpt
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r-- | Zend/zend_operators.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index ccd00b4e52..d27f5bf6f6 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -89,6 +89,13 @@ ZEND_API zend_uchar _is_numeric_string_ex(const char *str, size_t length, zend_l END_EXTERN_C() +#if SIZEOF_ZEND_LONG == 4 +# define ZEND_DOUBLE_FITS_LONG(d) (!((d) > ZEND_LONG_MAX || (d) < ZEND_LONG_MIN)) +#else + /* >= as (double)ZEND_LONG_MAX is outside signed range */ +# define ZEND_DOUBLE_FITS_LONG(d) (!((d) >= ZEND_LONG_MAX || (d) < ZEND_LONG_MIN)) +#endif + #if ZEND_DVAL_TO_LVAL_CAST_OK static zend_always_inline zend_long zend_dval_to_lval(double d) { @@ -103,7 +110,7 @@ static zend_always_inline zend_long zend_dval_to_lval(double d) { if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) { return 0; - } else if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) { + } else if (!ZEND_DOUBLE_FITS_LONG(d)) { double two_pow_32 = pow(2., 32.), dmod; @@ -122,8 +129,7 @@ static zend_always_inline zend_long zend_dval_to_lval(double d) { if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) { return 0; - /* >= as (double)ZEND_LONG_MAX is outside signed range */ - } else if (d >= ZEND_LONG_MAX || d < ZEND_LONG_MIN) { + } else if (!ZEND_DOUBLE_FITS_LONG(d)) { double two_pow_64 = pow(2., 64.), dmod; |