summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-06-14 02:00:55 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-06-14 02:00:55 +0200
commitf263932f38990ebee1353c8196deff440c3397d4 (patch)
tree7366ab5c267b7d6eed01d44cfe86beffd689775f /Zend
parent6084844fb5b93d3712d5b1376ed99bfa6c51b637 (diff)
downloadphp-git-f263932f38990ebee1353c8196deff440c3397d4.tar.gz
Fix short-circuting (bug #69825)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug69825.phpt30
-rw-r--r--Zend/zend_compile.c5
2 files changed, 34 insertions, 1 deletions
diff --git a/Zend/tests/bug69825.phpt b/Zend/tests/bug69825.phpt
new file mode 100644
index 0000000000..1349dee5ae
--- /dev/null
+++ b/Zend/tests/bug69825.phpt
@@ -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)
+
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 7e25c89781..f753af4483 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -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);