From c9a03558830abe7150e192c6dc12eaad0d60d980 Mon Sep 17 00:00:00 2001 From: Chansig Date: Sat, 31 Mar 2018 09:59:49 +0200 Subject: [PATCH] [HttpCache] Unlink tmp file on error --- src/Symfony/Component/HttpKernel/HttpCache/Store.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index fa0d4a8671..d20bfaa1b0 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -387,16 +387,22 @@ class Store implements StoreInterface $tmpFile = tempnam(dirname($path), basename($path)); if (false === $fp = @fopen($tmpFile, 'wb')) { + @unlink($tmpFile); + return false; } @fwrite($fp, $data); @fclose($fp); if ($data != file_get_contents($tmpFile)) { + @unlink($tmpFile); + return false; } if (false === @rename($tmpFile, $path)) { + @unlink($tmpFile); + return false; } }