com php-src: Fixed bug #74442: NEWS ext/opcache/Optimizer/dfa _pass.c ext/opcache/tests/bug74442.phpt
[email protected] (Nikita Popov)
| Newsgroups | php.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 2f22dffd1a4535520959943e2e9aec8b2b9b647f Author: Nikita Popov <[email protected]> Fri, 14 Apr 2017 22:20:32 +0200 Parents: 3ffe2cd251731d68493becf8ebbe6312ee86bb8d Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2f22dffd1a4535520959943e2e9aec8b2b9b647f Log: Fixed bug #74442 Bugs: https://bugs.php.net/74442 Changed paths: M NEWS M ext/opcache/Optimizer/dfa_pass.c A ext/opcache/tests/bug74442.phpt Diff: diff --git a/NEWS b/NEWS index 9953a67..6af7477 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,7 @@ PHP NEWS - Opcache: . Fixed bug #74431 (foreach infinite loop). (Nikita) + . Fixed bug #74442 (Opcached version produces a nested array). (Nikita) - OpenSSL: . Fixed bug #74341 (openssl_x509_parse fails to parse ASN.1 UTCTime without diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 4e42606..027814b 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -366,6 +366,12 @@ static zend_bool opline_supports_assign_contraction( && (opline->op2_type != IS_CV || opline->op2.var != cv_var); } + if (opline->opcode == ZEND_CAST) { + /* CAST to array/object may initialize the result to an empty array/object before + * reading the expression. */ + return opline->extended_value != IS_ARRAY && opline->extended_value != IS_OBJECT; + } + return 1; } diff --git a/ext/opcache/tests/bug74442.phpt b/ext/opcache/tests/bug74442.phpt new file mode 100644 index 0000000..6b02d49 --- /dev/null +++ b/ext/opcache/tests/bug74442.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #74442: Opcached version produces a nested array +--FILE-- +<?php +class Schema_Base { + public function addField($typeclass, array $params = null) { + $field = new $typeclass($params); + return $field; + } +} + +class Field_Base { + public function __construct(array $params = null) { + if (! is_array($params)) { + $params = (array) $params; + } + call_user_func_array(array($this, 'acceptParams'), $params); + } +} + +class Field_Integer extends Field_Base { + protected function acceptParams($bytes = 4) { + echo print_r($bytes, true); + } +} + +try { + $schema = new Schema_Base; + $schema->addField('Field_Integer'); +} catch (Throwable $ex) { + echo "CAUGHT EXCEPTION"; + echo (string)$ex; +} + +?> +--EXPECT-- +4