Skip to content

Commit

Permalink
[EventDispatcher] fix memory leak in a getListeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Sep 17, 2015
1 parent 4f9a411 commit ec59953
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Symfony/Component/EventDispatcher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public function dispatch($eventName, Event $event = null)
public function getListeners($eventName = null)
{
if (null !== $eventName) {
if (!isset($this->listeners[$eventName])) {
return array();
}

if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName);
}
Expand Down Expand Up @@ -177,9 +181,7 @@ private function sortListeners($eventName)
{
$this->sorted[$eventName] = array();

if (isset($this->listeners[$eventName])) {
krsort($this->listeners[$eventName]);
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
}
krsort($this->listeners[$eventName]);
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
}
}

0 comments on commit ec59953

Please sign in to comment.