Disable optimiser evaluation for numeric string errors

This commit is contained in:
Andrea Faulds 2016-02-14 01:25:57 +00:00
parent 30ee954ed1
commit d94c08852d
4 changed files with 11 additions and 1 deletions

View file

@ -6237,7 +6237,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */
} }
/* }}} */ /* }}} */
static inline zend_bool zend_binary_op_produces_numeric_string_error(uint32_t opcode, zval *op1, zval *op2) /* {{{ */ ZEND_API zend_bool zend_binary_op_produces_numeric_string_error(uint32_t opcode, zval *op1, zval *op2) /* {{{ */
{ {
if (!(opcode == ZEND_ADD || opcode == ZEND_SUB || opcode == ZEND_MUL || opcode == ZEND_DIV if (!(opcode == ZEND_ADD || opcode == ZEND_SUB || opcode == ZEND_MUL || opcode == ZEND_DIV
|| opcode == ZEND_POW || opcode == ZEND_MOD || opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_POW || opcode == ZEND_MOD || opcode == ZEND_SL || opcode == ZEND_SR

View file

@ -1023,6 +1023,8 @@ END_EXTERN_C()
/* The default value for CG(compiler_options) during eval() */ /* The default value for CG(compiler_options) during eval() */
#define ZEND_COMPILE_DEFAULT_FOR_EVAL 0 #define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
ZEND_API zend_bool zend_binary_op_produces_numeric_string_error(uint32_t opcode, zval *op1, zval *op2);
#endif /* ZEND_COMPILE_H */ #endif /* ZEND_COMPILE_H */
/* /*

View file

@ -683,9 +683,14 @@ optimize_constant_binary_op:
} else if ((opline->opcode == ZEND_SL || opline->opcode == ZEND_SR) && } else if ((opline->opcode == ZEND_SL || opline->opcode == ZEND_SR) &&
zval_get_long(&ZEND_OP2_LITERAL(opline)) < 0) { zval_get_long(&ZEND_OP2_LITERAL(opline)) < 0) {
SET_VAR_SOURCE(opline); SET_VAR_SOURCE(opline);
opline++;
continue;
} else if (zend_binary_op_produces_numeric_string_error(opline->opcode, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline))) {
SET_VAR_SOURCE(opline);
opline++; opline++;
continue; continue;
} }
printf("%d\n", opline->opcode);
er = EG(error_reporting); er = EG(error_reporting);
EG(error_reporting) = 0; EG(error_reporting) = 0;
if (binary_op(&result, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline)) == SUCCESS) { if (binary_op(&result, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline)) == SUCCESS) {

View file

@ -84,6 +84,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
zval_get_long(&ZEND_OP2_LITERAL(opline)) < 0) { zval_get_long(&ZEND_OP2_LITERAL(opline)) < 0) {
/* shift by negative number */ /* shift by negative number */
break; break;
} else if (zend_binary_op_produces_numeric_string_error(opline->opcode, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline))) {
/* produces numeric string E_NOTICE/E_WARNING */
break;
} }
er = EG(error_reporting); er = EG(error_reporting);
EG(error_reporting) = 0; EG(error_reporting) = 0;