com php-src: Fixed bug #71297 (Memory leak with yield from): NEWS Zend/tests/generators/bug71297.phpt Zend/zend_generators.c

From: Date: Thu, 07 Jan 2016 10:56:21 +0000
Subject: com php-src: Fixed bug #71297 (Memory leak with yield from): NEWS Zend/tests/generators/bug71297.phpt Zend/zend_generators.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90566@lists.php.net to get a copy of this message
Commit: 033d6087711332efab4fbb1cb90acabd9af8534b Author: Bob Weinand <bobwei9@hotmail.com> Thu, 7 Jan 2016 11:56:10 +0100 Parents: 42e0fff9287a36ca8af0eece820dff22fcea4342 Branches: PHP-7.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=033d6087711332efab4fbb1cb90acabd9af8534b Log: Fixed bug #71297 (Memory leak with yield from) Bugs: https://bugs.php.net/71297 Changed paths: M NEWS A Zend/tests/generators/bug71297.phpt M Zend/zend_generators.c Diff: diff --git a/NEWS b/NEWS index 758b70e..d33a8fd 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS (Bob) . Fixed bug #71273 (A wrong ext directory setup in php.ini leads to crash). (Anatol) + . Fixed bug #71297 (Memory leak with consecutive yield from). (Bob) - CURL: . Fixed bug #71225 (curl_setopt() fails to set CURLOPT_POSTFIELDS with diff --git a/Zend/tests/generators/bug71297.phpt b/Zend/tests/generators/bug71297.phpt new file mode 100644 index 0000000..eed7278 --- /dev/null +++ b/Zend/tests/generators/bug71297.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #71297 (Memory leak with consecutive yield from) +--FILE-- +<?php + +function foo() { + yield array_fill(0, 10000, 4); +} + +function genLeak() { + $i = 0; + while (1) { + yield from foo(); + print $i++; + } +} + +$x = 0; +foreach (genLeak() as $i) { + if ($x++ == 3) break; +} + +?> +--EXPECT-- +012 diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index b5e6c6a..09cbb9a 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -495,7 +495,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator if (EXPECTED(EG(exception) == NULL)) { zend_op *yield_from = (zend_op *) root->execute_data->opline - 1; - if (yield_from->opcode == ZEND_YIELD_FROM && !(yield_from->result_type & EXT_TYPE_UNUSED)) { + if (yield_from->opcode == ZEND_YIELD_FROM) { if (Z_ISUNDEF(root->node.parent->retval)) { /* Throw the exception in the context of the generator */ zend_execute_data *original_execute_data = EG(current_execute_data); @@ -512,6 +512,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator EG(current_execute_data) = original_execute_data; } else { + zval_dtor(&root->value); ZVAL_COPY(&root->value, &root->node.parent->value); ZVAL_COPY(ZEND_CALL_VAR(root->execute_data, yield_from->result.var), &root->node.parent->retval); }

« previous php.cvs (#90566) next »