Browse Source

Don't read past the end of $args

split-manual
J. King 5 years ago
parent
commit
5fb58054ff
  1. 14
      lib/Exception.php

14
lib/Exception.php

@ -61,11 +61,13 @@ class Exception extends \Exception {
$message = static::$messages[$code];
$previous = null;
// Grab a previous exception if there is one.
if ($args[0] instanceof \Throwable) {
$previous = array_shift($args);
} elseif (end($args) instanceof \Throwable) {
$previous = array_pop($args);
if ($args) {
// Grab a previous exception if there is one.
if ($args[0] instanceof \Throwable) {
$previous = array_shift($args);
} elseif (end($args) instanceof \Throwable) {
$previous = array_pop($args);
}
}
// Count the number of replacements needed in the message.
@ -84,4 +86,4 @@ class Exception extends \Exception {
parent::__construct($message, $code, $previous);
}
}
}

Loading…
Cancel
Save