1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00

Fcall optimization: Avoid FETCH_DIM_R with UNUSED op2

This commit is contained in:
Nikita Popov
2016-11-10 21:36:46 +01:00
parent 15ac490472
commit bb3d0c0e17
2 changed files with 22 additions and 0 deletions
@@ -112,6 +112,13 @@ void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
opline->extended_value &= ZEND_FETCH_TYPE_MASK;
opline->opcode -= 9;
} else {
if (opline->opcode == ZEND_FETCH_DIM_FUNC_ARG
&& opline->op2_type == IS_UNUSED) {
/* FETCH_DIM_FUNC_ARG supports UNUSED op2, while FETCH_DIM_R does not.
* Performing the replacement would create an invalid opcode. */
break;
}
opline->extended_value &= ZEND_FETCH_TYPE_MASK;
opline->opcode -= 12;
}
@@ -0,0 +1,15 @@
--TEST--
Don't create FETCH_DIM_R with UNUSED op2
--FILE--
<?php
// Order matters
test($arr[]);
function test($arg) {}
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot use [] for reading in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d