Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix segfault when send()ing to a closed generator

  • Loading branch information...
commit 12e928314fb270db31adc361ac4993b4f0fe000a 1 parent ad525c2
@nikic nikic authored
View
14 Zend/tests/generators/send_after_close.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Calls to send() after close should do nothing
+--FILE--
+<?php
+
+function *gen() { }
+
+$gen = gen();
+$gen->send("Test");
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
View
5 Zend/zend_generators.c
@@ -308,6 +308,11 @@ ZEND_METHOD(Generator, send)
zend_generator_ensure_initialized(object, generator TSRMLS_CC);
+ /* The generator is already closed, thus can't send anything */
+ if (!generator->execute_data) {
+ return;
+ }
+
/* The sent value was initialized to NULL, so dtor that */
zval_ptr_dtor(generator->send_target->var.ptr_ptr);
Please sign in to comment.
Something went wrong with that request. Please try again.