8000 Avoid infinite loops when profiler data is malformed · symfony/symfony@e5ef9fb · GitHub
[go: up one dir, main page]

Skip to content

Commit e5ef9fb

Browse files
committed
Avoid infinite loops when profiler data is malformed
1 parent e1ffb33 commit e5ef9fb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ public function write(Profile $profile)
144144
}
145145
}
146146

147+
$profileToken = $profile->getToken();
148+
// when there are errors in sub-requests, the parent and/or children tokens
149+
// may equal the profile token, resulting in infinite loops
150+
$parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null;
151+
$childrenToken = array_filter(array_map(function ($p) use ($profileToken) {
152+
return $profileToken !== $p->getToken() ? $p->getToken() : null;
153+
}, $profile->getChildren()));
154+
147155
// Store profile
148156
$data = array(
149-
'token' => $profile->getToken(),
150-
'parent' => $profile->getParentToken(),
151-
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
157+
'token' => $profileToken,
158+
'parent' => $parentToken,
159+
'children' => $childrenToken,
152160
'data' => $profile->getCollectors(),
153161
'ip' => $profile->getIp(),
154162
'method' => $profile->getMethod(),

0 commit comments

Comments
 (0)
0