com php-src: Backport narrowing fix to 7.1: ext/opcache/Optimiz er/zend_inference.c
| From: | Nikita Popov | Date: | Tue, 09 Jan 2018 17:41:46 +0000 |
| Subject: | com php-src: Backport narrowing fix to 7.1: ext/opcache/Optimiz er/zend_inference.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100818@lists.php.net to get a copy of this message | ||
Commit: f208187773edd9423e64b5b4dd16b146260c780d
Author: Nikita Popov <nikita.ppv@gmail.com> Sat, 16 Dec 2017 21:11:40 +0100
Parents: 6da44fefb2065e28c6329f45b40c5611f86f4bf3
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f208187773edd9423e64b5b4dd16b146260c780d
Log:
Backport narrowing fix to 7.1
This is a cherry-pick of 8a4532319dfae83ff16b2d2bbfeed062924c3c27.
Changed paths:
M ext/opcache/Optimizer/zend_inference.c
Diff:
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index db232df..aeb30c8 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -2157,6 +2157,24 @@ static int zend_update_type_info(const zend_op_array *op_array,
t1 = OP1_INFO();
t2 = OP2_INFO();
+ /* If one of the operands cannot have any type, this means the operand derives from
+ * unreachable code. Propagate the empty result early, so that that the following
+ * code may assume that operands have at least one type. */
+ if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS|MAY_BE_ERROR))
+ || !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS|MAY_BE_ERROR))) {
+ tmp = 0;
+ if (ssa_ops[i].result_def >= 0) {
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
+ }
+ if (ssa_ops[i].op1_def >= 0) {
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
+ }
+ if (ssa_ops[i].op2_def >= 0) {
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].op2_def);
+ }
+ return 1;
+ }
+
switch (opline->opcode) {
case ZEND_ADD:
case ZEND_SUB: