]> granicus.if.org Git - php/commitdiff
Fixed bug #80255
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 19 Oct 2020 13:13:40 +0000 (15:13 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 19 Oct 2020 13:13:53 +0000 (15:13 +0200)
This was a copy&paste mistake, target_block was used where
follow_block was intended. Also update copy&paste mistakes in
the comments.

NEWS
Zend/tests/bug80255.phpt [new file with mode: 0644]
ext/opcache/Optimizer/block_pass.c

diff --git a/NEWS b/NEWS
index 736ae5e0a32198890adbf50f3f6895a5466ccbf3..54948f11347b2e38148a9866463efadfebc045ca 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ PHP                                                                        NEWS
 - IMAP:
   . Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
 
+- Opcache:
+  . Fixed bug #80255 (Opcache bug (bad condition result) in 8.0.0rc1). (Nikita)
+
 15 Oct 2020, PHP 8.0.0RC2
 
 - Core:
diff --git a/Zend/tests/bug80255.phpt b/Zend/tests/bug80255.phpt
new file mode 100644 (file)
index 0000000..d3fc6b7
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #80255: Opcache bug (bad condition result) in 8.0.0rc1
+--FILE--
+<?php
+
+function test($a, $b, $c) {
+    do {
+        if ($a && !$b) {
+            break;
+        } else if ($b) {
+            echo "foo\n";
+        }
+        echo "bar\n";
+    } while ($c);
+    echo "baz\n";
+}
+
+test(true, true, false);
+
+?>
+--EXPECT--
+foo
+bar
+baz
index 5b6870ed0a66a37ea0072ba5f5f8b40d4a65a6f9..bad814ed6ea8c7e32436104b57b6e15b570f4f39 100644 (file)
@@ -1516,16 +1516,16 @@ optimize_jmpznz:
                                target = op_array->opcodes + follow_block->start;
 
                                if (target->opcode == ZEND_JMP) {
-                                       /* JMPZNZ(X, L1, L2), L1: JMP(L3) -> JMPZNZ(X, L3, L2) */
+                                       /* JMPZNZ(X, L1, L2), L2: JMP(L3) -> JMPZNZ(X, L1, L3) */
                                        next = follow_block->successors[0];
                                } else if (target->opcode == ZEND_JMPNZ &&
                                           SAME_VAR(target->op1, last_op->op1)) {
-                                       /* JMPZNZ(X, L1, L2), L1: X = JMPNZ(X, L3) -> JMPZNZ(X, L1+1, L2) */
+                                       /* JMPZNZ(X, L1, L2), L2: X = JMPNZ(X, L3) -> JMPZNZ(X, L1, L3) */
                                        next = follow_block->successors[0];
                                } else if ((target->opcode == ZEND_JMPZ || target->opcode == ZEND_JMPZNZ) &&
                                           SAME_VAR(target->op1, last_op->op1)) {
-                                       /* JMPZNZ(X, L1, L2), L1: JMPZ(X, L3) -> JMPZNZ(X, L3, L2) */
-                                       next = target_block->successors[1];
+                                       /* JMPZNZ(X, L1, L2), L2: JMPZ(X, L3) -> JMPZNZ(X, L1, L2+1) */
+                                       next = follow_block->successors[1];
                                } else {
                                        break;
                                }