summaryrefslogtreecommitdiff
path: root/Zend/zend_API.h
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2014-12-13 18:38:15 +0000
committerAndrea Faulds <ajf@ajf.me>2014-12-13 18:38:15 +0000
commit0ea0b591d79ae0ee18d33533a5c701330836ff6b (patch)
tree8612c30a23ce7ed8ed0d376f571597ddc7c5d171 /Zend/zend_API.h
parentde0afce55b085f9983f9d49ced5244f748b30750 (diff)
parentd5afeef24742be2c2f6b7a8b0932301eca0f9968 (diff)
downloadphp-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.h')
-rw-r--r--Zend/zend_API.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 052214140f..1e031ca844 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -1064,10 +1064,16 @@ static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_boo
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
*dest = Z_LVAL_P(arg);
} else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
- if (strict && UNEXPECTED(Z_DVAL_P(arg) > ZEND_LONG_MAX)) {
- *dest = ZEND_LONG_MAX;
- } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < ZEND_LONG_MIN)) {
- *dest = ZEND_LONG_MIN;
+ if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
+ return 0;
+ }
+ if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) {
+ /* Ironically, the strict parameter makes zpp *non*-strict here */
+ if (strict) {
+ *dest = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
+ } else {
+ return 0;
+ }
} else {
*dest = zend_dval_to_lval(Z_DVAL_P(arg));
}
@@ -1077,10 +1083,15 @@ static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_boo
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
if (EXPECTED(type != 0)) {
- if (strict && UNEXPECTED(d > ZEND_LONG_MAX)) {
- *dest = ZEND_LONG_MAX;
- } else if (strict && UNEXPECTED(d < ZEND_LONG_MIN)) {
- *dest = ZEND_LONG_MIN;
+ if (UNEXPECTED(zend_isnan(d))) {
+ return 0;
+ }
+ if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) {
+ if (strict) {
+ *dest = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
+ } else {
+ return 0;
+ }
} else {
*dest = zend_dval_to_lval(d);
}