Skip to content

Commit 4a8a18e

Browse files
[Debug] prevent infinite loop with faulty exception handlers
1 parent fad59b3 commit 4a8a18e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

+6
Original file line numberDiff line numberDiff line change
@@ -561,16 +561,22 @@ public static function handleFatalError(array $error = null)
561561

562562
$handler = self::$reservedMemory = null;
563563
$handlers = array();
564+
$previousHandler = null;
565+
$previousHandlerLimit = 10;
564566

565567
while (!is_array($handler) || !$handler[0] instanceof self) {
566568
$handler = set_exception_handler('var_dump');
567569
restore_exception_handler();
568570

571+
if ($handler === $previousHandler && !--$previousHandlerLimit) {
572+
$handler = null;
573+
}
569574
if (!$handler) {
570575
break;
571576
}
572577
restore_exception_handler();
573578
array_unshift($handlers, $handler);
579+
$previousHandler = $handler;
574580
}
575581
foreach ($handlers as $h) {
576582
set_exception_handler($h);

0 commit comments

Comments
 (0)