]> granicus.if.org Git - php/commitdiff
Fix bug #80184
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 5 Oct 2020 13:23:31 +0000 (15:23 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 5 Oct 2020 13:24:51 +0000 (15:24 +0200)
NEWS
Zend/tests/bug80184.phpt [new file with mode: 0644]
ext/opcache/Optimizer/block_pass.c

diff --git a/NEWS b/NEWS
index b0e4d74d2810f7d14eaee9df5b8331933a71cc6d..00f463c4915d0f045b1d52a736e2a4de3c96db0c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP                                                                        NEWS
   . Fixed bug #80121 (Null pointer deref if CurlHandle directly instantiated).
     (Nikita)
 
+- Opcache:
+  . Fixed bug #80184 (Complex expression in while / if statements resolves to
+    false incorrectly). (Nikita)
+
 - SPL:
   . Fixed bug #65387 (Circular references in SPL iterators are not garbage
     collected). (Nikita)
diff --git a/Zend/tests/bug80184.phpt b/Zend/tests/bug80184.phpt
new file mode 100644 (file)
index 0000000..1d12799
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #80184: Complex expression in while / if statements resolves to false incorrectly
+--FILE--
+<?php
+
+$callbacks = [
+       function () { echo "First item!\n"; },
+       function () { echo "Second item!\n"; },
+       function () { echo "Third item!\n"; },
+       function () { echo "Fourth item!\n"; },
+];
+
+while ($callback = array_shift($callbacks) and ($callback() || true));
+
+?>
+--EXPECT--
+First item!
+Second item!
+Third item!
+Fourth item!
index 7b9fb2afca7f784c26b352a344127cfbdb780b2f..d8a0e419f1b45a0eb5945534e7109aa7a9712b2d 100644 (file)
@@ -1371,6 +1371,7 @@ static void zend_jmp_optimization(zend_basic_block *block, zend_op_array *op_arr
                                                        MAKE_NOP(last_op);
                                                        block->len--;
                                                }
+                                               block->successors[0] = follow_block - cfg->blocks;
                                                block->successors_count = 1;
                                                ++(*opt_count);
                                                break;