From c562d44321ea69612fbe3f7460055e9ed4340baa Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sat, 22 Jul 2017 20:58:54 -0400 Subject: Fix compile-time optimization of NAN comparisons --- Zend/zend_operators.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Zend/zend_operators.c') diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 3a8929b83f..0b4d82b5d5 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2151,6 +2151,16 @@ ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval * ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ { + if (UNEXPECTED((Z_TYPE_P(op1) == IS_DOUBLE) && isnan(Z_DVAL_P(op1)))) { + ZVAL_FALSE(result); + return SUCCESS; + } + + if (UNEXPECTED((Z_TYPE_P(op2) == IS_DOUBLE) && isnan(Z_DVAL_P(op2)))) { + ZVAL_FALSE(result); + return SUCCESS; + } + if (compare_function(result, op1, op2) == FAILURE) { return FAILURE; } @@ -2161,6 +2171,16 @@ ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { + if (UNEXPECTED((Z_TYPE_P(op1) == IS_DOUBLE) && isnan(Z_DVAL_P(op1)))) { + ZVAL_FALSE(result); + return SUCCESS; + } + + if (UNEXPECTED((Z_TYPE_P(op2) == IS_DOUBLE) && isnan(Z_DVAL_P(op2)))) { + ZVAL_FALSE(result); + return SUCCESS; + } + if (compare_function(result, op1, op2) == FAILURE) { return FAILURE; } -- cgit v1.2.1