Skip to content

Commit 5f397f8

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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ public static function handleFatalError(array $error = null)
561561

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

565567
while (!is_array($handler) || !$handler[0] instanceof self) {
566568
$handler = set_exception_handler('var_dump');
@@ -570,7 +572,14 @@ public static function handleFatalError(array $error = null)
570572
break;
571573
}
572574
restore_exception_handler();
573-
array_unshift($handlers, $handler);
575+
576+
if ($handler !== $previousHandler) {
577+
array_unshift($handlers, $handler);
578+
$previousHandler = $handler;
579+
} elseif (0 === --$sameHandlerLimit) {
580+
$handler = null;
581+
break;
582+
}
574583
}
575584
foreach ($handlers as $h) {
576585
set_exception_handler($h);

0 commit comments

Comments
 (0)