From b94c430dd82e381aeda924a1038616bf4bef874e Mon Sep 17 00:00:00 2001 From: Nicolas Corder Date: Tue, 14 Sep 2021 11:54:39 -0700 Subject: [PATCH] Add output buffer length check before attempting to end it --- src/Whoops/Run.php | 2 +- src/Whoops/Util/SystemFacade.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Whoops/Run.php b/src/Whoops/Run.php index 52486d0d..14bd1bfe 100644 --- a/src/Whoops/Run.php +++ b/src/Whoops/Run.php @@ -393,7 +393,7 @@ public function handleException($exception) // @todo Might be able to clean this up a bit better if ($willQuit) { // Cleanup all other output buffers before sending our output: - while ($this->system->getOutputBufferLevel() > 0) { + while ($this->system->getOutputBufferLevel() > 0 && $this->system->getOutputBufferLength() > 0) { $this->system->endOutputBuffering(); } diff --git a/src/Whoops/Util/SystemFacade.php b/src/Whoops/Util/SystemFacade.php index 9eb0acfa..4d1c35b6 100644 --- a/src/Whoops/Util/SystemFacade.php +++ b/src/Whoops/Util/SystemFacade.php @@ -77,6 +77,14 @@ public function cleanOutputBuffer() return ob_get_clean(); } + /** + * @return int + */ + public function getOutputBufferLength() + { + return ob_get_length(); + } + /** * @return int */