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_API.c | |
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_API.c')
-rw-r--r-- | Zend/zend_API.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 2e13f3a20e..788da61474 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -404,14 +404,16 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), p, &d, -1)) == 0) { return "long"; } else if (type == IS_DOUBLE) { - if (c == 'L') { - if (d > ZEND_LONG_MAX) { - *p = ZEND_LONG_MAX; - break; - } else if (d < ZEND_LONG_MIN) { - *p = ZEND_LONG_MIN; - break; + if (zend_isnan(d)) { + return "long"; + } + if (!ZEND_DOUBLE_FITS_LONG(d)) { + if (c == 'L') { + *p = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN; + } else { + return "long"; } + break; } *p = zend_dval_to_lval(d); @@ -420,14 +422,16 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons break; case IS_DOUBLE: - if (c == 'L') { - if (Z_DVAL_P(arg) > ZEND_LONG_MAX) { - *p = ZEND_LONG_MAX; - break; - } else if (Z_DVAL_P(arg) < ZEND_LONG_MIN) { - *p = ZEND_LONG_MIN; - break; + if (zend_isnan(Z_DVAL_P(arg))) { + return "long"; + } + if (!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg))) { + if (c == 'L') { + *p = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN; + } else { + return "long"; } + break; } case IS_NULL: case IS_FALSE: |