From 44454ac28aead764e8c1610e85e476973c00e8a9 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 28 Oct 2021 17:36:02 +0100 Subject: [PATCH] [UTIL][TemporaryFile] Ensure `resource` is neither `false` nor `null` when attempting to cleanup, otherwise `getRealPath` returns `false` and we get sad --- src/Util/TemporaryFile.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Util/TemporaryFile.php b/src/Util/TemporaryFile.php index aa785c7299..c4770db561 100644 --- a/src/Util/TemporaryFile.php +++ b/src/Util/TemporaryFile.php @@ -126,8 +126,11 @@ class TemporaryFile extends SplFileInfo */ protected function cleanup(): void { - if ($this->resource !== false) { + if (!\is_null($this->resource) && $this->resource !== false) { $path = $this->getRealPath(); + if ($path === false) { + throw new BugFoundException(); + } $this->close(); if (file_exists($path)) { @unlink($path);