Fix short-circuting (bug #69825)

This commit is contained in:
Bob Weinand 2015-06-14 02:00:55 +02:00
parent 6084844fb5
commit f263932f38
2 changed files with 34 additions and 1 deletions

30
Zend/tests/bug69825.phpt Normal file
View File

@ -0,0 +1,30 @@
--TEST--
Bug #69825 (Short-circuiting failure)
--FILE--
<?php
print "AND\n";
var_dump(0 && 1);
var_dump(0 && 0);
var_dump(1 && 0);
var_dump(1 && 1);
print "OR\n";
var_dump(0 || 1);
var_dump(0 || 0);
var_dump(1 || 0);
var_dump(1 || 1);
?>
--EXPECT--
AND
bool(false)
bool(false)
bool(false)
bool(true)
OR
bool(true)
bool(false)
bool(true)
bool(true)

View File

@ -5854,7 +5854,10 @@ void zend_compile_short_circuiting(znode *result, zend_ast *ast) /* {{{ */
zend_compile_expr(&right_node, right_ast);
if (right_node.op_type == IS_CONST) {
if (right_node.op_type == IS_CONST && (
(ast->kind == ZEND_AST_AND && !zend_is_true(&right_node.u.constant))
|| (ast->kind == ZEND_AST_OR && zend_is_true(&right_node.u.constant))
)) {
result->op_type = IS_CONST;
ZVAL_BOOL(&result->u.constant, zend_is_true(&right_node.u.constant));
zval_ptr_dtor(&right_node.u.constant);