Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #44685
  • Loading branch information
dstogov committed Feb 18, 2022
1 parent 8f5480e commit 84a638a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
@@ -0,0 +1,17 @@
--TEST--
Memory leak when resume an already running generator
--FILE--
<?php
function gen() {
$g = yield;
$g->send($g);
}
$gen = gen();
try {
$gen->send($gen);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Cannot resume an already running generator
1 change: 1 addition & 0 deletions Zend/zend_generators.c
Expand Up @@ -924,6 +924,7 @@ ZEND_METHOD(Generator, send)
root = zend_generator_get_current(generator);
/* Put sent value in the target VAR slot, if it is used */
if (root->send_target) {
zval_ptr_dtor(root->send_target);
ZVAL_COPY(root->send_target, value);
}

Expand Down

0 comments on commit 84a638a

Please sign in to comment.