]> granicus.if.org Git - php/commitdiff
Fixed bug #66474 (Optimizer bug in constant string to boolean conversion)
authorDmitry Stogov <dmitry@zend.com>
Mon, 13 Jan 2014 08:06:19 +0000 (12:06 +0400)
committerDmitry Stogov <dmitry@zend.com>
Mon, 13 Jan 2014 08:06:19 +0000 (12:06 +0400)
NEWS
ext/opcache/Optimizer/block_pass.c
ext/opcache/tests/bug66474.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 5979ab1e431e7b4a8026460de11acca4b3423b8f..07a9e7f864f2272c8afb0bf46f0fd4389cc5614e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ PHP                                                                        NEWS
     (Laruence, Remi)
 
 - OPCache:
+  . Fixed bug #66474 (Optimizer bug in constant string to boolean conversion).
+    (Dmitry)
   . Fixed bug #66298 (ext/opcache/Optimizer/zend_optimizer.c has dos-style 
     ^M as lineend). (Laruence)
 
index 8c4c58e4936e494ff88eeb7b86ab7097bf8954d2..79eee8bcc14165420aa1792b0a307dd98b2499a4 100644 (file)
@@ -1057,6 +1057,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
                                /* BOOL */
                                result = ZEND_OP1_LITERAL(opline);
                                convert_to_boolean(&result);
+                               Z_TYPE(ZEND_OP1_LITERAL(opline)) = IS_NULL;
                        }
                        PZ_SET_REFCOUNT_P(&result, 1);
                        PZ_UNSET_ISREF_P(&result);
diff --git a/ext/opcache/tests/bug66474.phpt b/ext/opcache/tests/bug66474.phpt
new file mode 100644 (file)
index 0000000..3bd038c
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #66474 (Optimizer bug in constant string to boolean conversion)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function foo() {
+       $speed = 'slow' || 'fast';
+}
+foo();
+echo "ok\n";
+--EXPECT--
+ok