From ccbf3059ba6cb497f2337f6eb348e52189c4915a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 8 Apr 2020 16:40:56 +0200 Subject: [PATCH] Close the streams in `writeStream` even when there is an exception Signed-off-by: Robin Appelman --- lib/private/Files/Storage/Common.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index f2d427227c9..1921e5f21d7 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -858,9 +858,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { if (!$target) { return 0; } - list($count, $result) = \OC_Helper::streamCopy($stream, $target); - fclose($stream); - fclose($target); + try { + [$count, $result] = \OC_Helper::streamCopy($stream, $target); + } finally { + fclose($target); + fclose($stream); + } return $count; } } -- 2.39.5