From b97df475dfbfe5c7ddd883432eb3bcf3645803e9 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 22 Jun 2015 12:53:52 +0300 Subject: [PATCH] Fixed crash in Zend/tests/bug69891.phpt on x86 (32-bit). compare_function() now has to be compatible with binary_op_type (use fastcall convention). Introduced new zval_compare_function() to be used as zval comparison callback instead of compare_function(). --- Zend/zend_operators.c | 14 +++++++++++++- Zend/zend_operators.h | 3 ++- ext/standard/array.c | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7e3b458bbe..26584745dc 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1760,7 +1760,7 @@ static inline void zend_free_obj_get_result(zval *op) /* {{{ */ } /* }}} */ -ZEND_API int compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline int i_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ { int ret; int converted = 0; @@ -1942,6 +1942,18 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ } /* }}} */ +ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +{ + return i_compare_function(result, op1, op2); +} +/* }}} */ + +ZEND_API int zval_compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +{ + return i_compare_function(result, op1, op2); +} +/* }}} */ + static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */ { zval result; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 17d1bcffb4..601508ca27 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -327,7 +327,8 @@ again: return result; } -ZEND_API int compare_function(zval *result, zval *op1, zval *op2); +ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2); +ZEND_API int zval_compare_function(zval *result, zval *op1, zval *op2); ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2); ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive); ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2); diff --git a/ext/standard/array.c b/ext/standard/array.c index fdfb9107d9..a998079d64 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -164,7 +164,7 @@ static void php_set_compare_func(zend_long sort_type) /* {{{ */ case PHP_SORT_REGULAR: default: - ARRAYG(compare_func) = compare_function; + ARRAYG(compare_func) = zval_compare_function; break; } } -- 2.40.0