]> granicus.if.org Git - php/commitdiff
Fix off by one in short_circuiting optimization
authorBob Weinand <bobwei9@hotmail.com>
Sun, 14 Jun 2015 15:08:39 +0000 (17:08 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 14 Jun 2015 15:47:35 +0000 (17:47 +0200)
Zend/zend_compile.c

index 6164242dc0668fad9a5c5bff449847de1367dafe..bd7b65f1e86de5ad5d78998f8e0c7a5bd4fb8dad 100644 (file)
@@ -5842,7 +5842,7 @@ void zend_compile_short_circuiting(znode *result, zend_ast *ast) /* {{{ */
 
        if (left_node.op_type == IS_CONST) {
                if ((ast->kind == ZEND_AST_AND && !zend_is_true(&left_node.u.constant))
-                   || (ast->kind == ZEND_AST_OR && zend_is_true(&left_node.u.constant))) {
+                || (ast->kind == ZEND_AST_OR && zend_is_true(&left_node.u.constant))) {
                        result->op_type = IS_CONST;
                        ZVAL_BOOL(&result->u.constant, zend_is_true(&left_node.u.constant));
                } else {
@@ -5875,9 +5875,9 @@ void zend_compile_short_circuiting(znode *result, zend_ast *ast) /* {{{ */
 
        zend_compile_expr(&right_node, right_ast);
 
-       if (right_node.op_type == IS_CONST && opnum_jmpz == CG(active_op_array)->last) {
+       if (right_node.op_type == IS_CONST && opnum_jmpz == get_next_op_number(CG(active_op_array)) - 1) {
                if ((ast->kind == ZEND_AST_AND && !zend_is_true(&right_node.u.constant))
-                       || (ast->kind == ZEND_AST_OR && zend_is_true(&right_node.u.constant))) {
+                || (ast->kind == ZEND_AST_OR && zend_is_true(&right_node.u.constant))) {
                        CG(active_op_array)->last--;
                        result->op_type = IS_CONST;
                        ZVAL_BOOL(&result->u.constant, zend_is_true(&right_node.u.constant));