Skip to content

Commit 123cd86

Browse files
committed
Change $this parameter in closure to $that to prevent memory leak.
Using `$this` as a parameter name in a closure under PHP 7 causes a memory leak under some specific circumstances which are present in this component. Relevant PHP issue: https://bugs.php.net/bug.php?id=71737 More information: https://gist.github.com/jmalloc/e3db5842c2c4ab2a1edf
1 parent ea34298 commit 123cd86

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Request.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ public function write($data)
9191
}
9292

9393
if (!count($this->pendingWrites)) {
94-
$this->on('headers-written', function ($this) {
95-
foreach ($this->pendingWrites as $pw) {
96-
$this->write($pw);
94+
$this->on('headers-written', function ($that) {
95+
foreach ($that->pendingWrites as $pw) {
96+
$that->write($pw);
9797
}
98-
$this->pendingWrites = array();
99-
$this->emit('drain', array($this));
98+
$that->pendingWrites = array();
99+
$that->emit('drain', array($that));
100100
});
101101
}
102102

0 commit comments

Comments
 (0)