diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-29 13:05:02 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-29 13:05:02 +0100 |
| commit | 26327bcd3b6375a4883f00a289ba129e5b23717d (patch) | |
| tree | 0ec16fe8034692b364af3c9c3d4f7f7bed9e0bf0 /Zend/zend_operators.c | |
| parent | 8f20b9969fb431cebc329995782631e8b5ecf6c2 (diff) | |
| download | php-git-26327bcd3b6375a4883f00a289ba129e5b23717d.tar.gz | |
Throw "Unsupported operand types" error when using ** on arrays
Diffstat (limited to 'Zend/zend_operators.c')
| -rw-r--r-- | Zend/zend_operators.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 69ee522b4c..a1f3024d4e 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1197,37 +1197,22 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* { } else if (!converted) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_POW, pow_function); - if (EXPECTED(op1 != op2)) { - if (Z_TYPE_P(op1) == IS_ARRAY) { - if (op1 == result) { - zval_ptr_dtor(result); - } - ZVAL_LONG(result, 0); - return SUCCESS; - } else { - op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0); - } - if (Z_TYPE_P(op2) == IS_ARRAY) { - if (op1 == result) { - zval_ptr_dtor(result); - } - ZVAL_LONG(result, 1L); - return SUCCESS; - } else { - op2 = zendi_convert_scalar_to_number(op2, &op2_copy, result, 0); + if (Z_TYPE_P(op1) == IS_ARRAY || Z_TYPE_P(op2) == IS_ARRAY) { + if (result != op1) { + ZVAL_UNDEF(result); } + zend_throw_error(NULL, "Unsupported operand types"); + return FAILURE; + } + + if (EXPECTED(op1 != op2)) { + op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0); + op2 = zendi_convert_scalar_to_number(op2, &op2_copy, result, 0); } else { - if (Z_TYPE_P(op1) == IS_ARRAY) { - if (op1 == result) { - zval_ptr_dtor(result); - } - ZVAL_LONG(result, 0); - return SUCCESS; - } else { - op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0); - } + op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0); op2 = op1; } + if (EG(exception)) { if (result != op1) { ZVAL_UNDEF(result); |
