Merge branch 'master' into temporary_cleaning

* master:
  Throw TypeError for invalid callback
  Fix crash when exception occurs during nested rope
  Fix crash when exception is thrown during ROPE_END
  Small cleanup in ternary compilation
  move the define to the right place
  fix ext/ldap build
  Rectify information about invalid shift warning being now ArithmeticError
This commit is contained in:
Dmitry Stogov 2015-07-07 04:41:54 +03:00
commit 1f5084b990
9 changed files with 78 additions and 19 deletions

View File

@ -255,10 +255,10 @@ Changes to integer handling
ignored. As such $i previously held the value 7, because the last two digits
were silently discarded.
* Bitwise shifts by negative numbers will now throw a warning and return false:
* Bitwise shifts by negative numbers will now throw an ArithmeticError:
var_dump(1 >> -1); // bool(false)
// Warning: Bit shift by negative number
var_dump(1 >> -1);
// ArithmeticError: Bit shift by negative number
* Left bitwise shifts by a number of bits beyond the bit width of an integer
will always result in 0:

View File

@ -0,0 +1,17 @@
--TEST--
Exception during nested rope
--FILE--
<?php
set_error_handler(function() { throw new Exception; });
try {
$a = "foo";
$str = "$a${"y$a$a"}y";
} catch (Exception $e) {
echo "Exception\n";
}
?>
--EXPECT--
Exception

View File

@ -0,0 +1,17 @@
--TEST--
Exception during rope finalization
--FILE--
<?php
set_error_handler(function() { throw new Exception; });
try {
$b = "foo";
$str = "y$b$a";
} catch (Exception $e) {
echo "Exception\n";
}
?>
--EXPECT--
Exception

View File

@ -245,7 +245,7 @@ ZEND_API void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, cha
zend_internal_type_error(ZEND_ARG_USES_STRICT_TYPES(), "%s%s%s() expects parameter %d to be a valid callback, %s",
class_name, space, get_active_function_name(), num, error);
} else if (severity == E_ERROR) {
zend_throw_error(zend_ce_error, "%s%s%s() expects parameter %d to be a valid callback, %s",
zend_throw_error(zend_ce_type_error, "%s%s%s() expects parameter %d to be a valid callback, %s",
class_name, space, get_active_function_name(), num, error);
} else {
zend_error(severity, "%s%s%s() expects parameter %d to be a valid callback, %s",

View File

@ -1924,6 +1924,7 @@ static inline void zend_update_jump_target(uint32_t opnum_jump, uint32_t opnum_t
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
case ZEND_JMP_SET:
opline->op2.opline_num = opnum_target;
break;
EMPTY_SWITCH_DEFAULT_CASE()
@ -6037,7 +6038,7 @@ static void zend_compile_shorthand_conditional(znode *result, zend_ast *ast) /*
zend_ast *false_ast = ast->child[2];
znode cond_node, false_node;
zend_op *opline_jmp_set, *opline_qm_assign;
zend_op *opline_qm_assign;
uint32_t opnum_jmp_set;
ZEND_ASSERT(ast->child[1] == NULL);
@ -6049,10 +6050,10 @@ static void zend_compile_shorthand_conditional(znode *result, zend_ast *ast) /*
zend_compile_expr(&false_node, false_ast);
opline_jmp_set = &CG(active_op_array)->opcodes[opnum_jmp_set];
opline_jmp_set->op2.opline_num = get_next_op_number(CG(active_op_array)) + 1;
opline_qm_assign = zend_emit_op_tmp(NULL, ZEND_QM_ASSIGN, &false_node, NULL);
SET_NODE(opline_qm_assign->result, result);
zend_update_jump_target_to_next(opnum_jmp_set);
}
/* }}} */
@ -6063,8 +6064,8 @@ void zend_compile_conditional(znode *result, zend_ast *ast) /* {{{ */
zend_ast *false_ast = ast->child[2];
znode cond_node, true_node, false_node;
zend_op *opline_qm_assign1, *opline_qm_assign2;
uint32_t opnum_jmpz, opnum_jmp, opnum_qm_assign1;
zend_op *opline_qm_assign2;
uint32_t opnum_jmpz, opnum_jmp;
if (!true_ast) {
zend_compile_shorthand_conditional(result, ast);
@ -6077,7 +6078,6 @@ void zend_compile_conditional(znode *result, zend_ast *ast) /* {{{ */
zend_compile_expr(&true_node, true_ast);
opnum_qm_assign1 = get_next_op_number(CG(active_op_array));
zend_emit_op_tmp(result, ZEND_QM_ASSIGN, &true_node, NULL);
opnum_jmp = zend_emit_jump(0);
@ -6086,8 +6086,7 @@ void zend_compile_conditional(znode *result, zend_ast *ast) /* {{{ */
zend_compile_expr(&false_node, false_ast);
opline_qm_assign1 = &CG(active_op_array)->opcodes[opnum_qm_assign1];
opline_qm_assign2 = zend_emit_op(NULL, opline_qm_assign1->opcode, &false_node, NULL);
opline_qm_assign2 = zend_emit_op(NULL, ZEND_QM_ASSIGN, &false_node, NULL);
SET_NODE(opline_qm_assign2->result, result);
zend_update_jump_target_to_next(opnum_jmp);

View File

@ -2381,9 +2381,14 @@ static zend_always_inline void i_cleanup_unfinished_execution(zend_execute_data
if ((var & ZEND_LIVE_MASK) == ZEND_LIVE_ROPE) {
/* free incomplete rope */
zend_string **rope = (zend_string **) EX_VAR(var & ~ZEND_LIVE_ROPE);
zend_op *last = EX(func)->op_array.opcodes + op_num;
while (last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT) {
zend_string **rope;
zend_op *last;
var = var & ~ZEND_LIVE_ROPE;
rope = (zend_string **) EX_VAR(var);
last = EX(func)->op_array.opcodes + op_num;
while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT)
|| last->result.var != var) {
ZEND_ASSERT(last >= EX(func)->op_array.opcodes);
last--;
}

View File

@ -2859,7 +2859,12 @@ ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV)
}
rope[opline->extended_value] = _zval_get_string_func(var);
FREE_OP2();
CHECK_EXCEPTION();
if (UNEXPECTED(EG(exception))) {
for (i = 0; i <= opline->extended_value; i++) {
zend_string_release(rope[i]);
}
HANDLE_EXCEPTION();
}
}
}
for (i = 0; i <= opline->extended_value; i++) {

View File

@ -12980,7 +12980,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CONST_HANDLE
}
rope[opline->extended_value] = _zval_get_string_func(var);
CHECK_EXCEPTION();
if (UNEXPECTED(EG(exception))) {
for (i = 0; i <= opline->extended_value; i++) {
zend_string_release(rope[i]);
}
HANDLE_EXCEPTION();
}
}
}
for (i = 0; i <= opline->extended_value; i++) {
@ -14264,7 +14269,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CV_HANDLER(Z
}
rope[opline->extended_value] = _zval_get_string_func(var);
CHECK_EXCEPTION();
if (UNEXPECTED(EG(exception))) {
for (i = 0; i <= opline->extended_value; i++) {
zend_string_release(rope[i]);
}
HANDLE_EXCEPTION();
}
}
}
for (i = 0; i <= opline->extended_value; i++) {
@ -14777,7 +14787,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_TMPVAR_HANDL
}
rope[opline->extended_value] = _zval_get_string_func(var);
zval_ptr_dtor_nogc(free_op2);
CHECK_EXCEPTION();
if (UNEXPECTED(EG(exception))) {
for (i = 0; i <= opline->extended_value; i++) {
zend_string_release(rope[i]);
}
HANDLE_EXCEPTION();
}
}
}
for (i = 0; i <= opline->extended_value; i++) {

View File

@ -22,6 +22,7 @@ if (PHP_LDAP != "no") {
AC_DEFINE('HAVE_LDAP_SASL', 1);
AC_DEFINE('HAVE_LDAP_SASL_SASL_H', 1);
AC_DEFINE('LDAP_DEPRECATED', 1);
AC_DEFINE('HAVE_LDAP_CONTROL_FIND', 1);
} else {
WARNING("ldap not enabled; libraries and headers not found");