From 0cc77d2c992ec99c2abccacd4a0c7be3927178d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Wed, 27 Jun 2018 17:44:41 +0200 Subject: [PATCH] [ticket/15342] Check if is resource before close it PHPBB3-15342 --- phpBB/includes/acp/acp_database.php | 5 ++++- phpBB/phpbb/attachment/upload.php | 8 +++++++- phpBB/phpbb/files/filespec_storage.php | 8 +++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index b6dbc4bec2..cb40ac547e 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -187,7 +187,10 @@ class acp_database $storage->write_stream($file, $fp); - fclose($fp); + if (is_resource($fp)) + { + fclose($fp); + } $storage->track_file($file); diff --git a/phpBB/phpbb/attachment/upload.php b/phpBB/phpbb/attachment/upload.php index 8d4b68c7be..b4e59f5c1f 100644 --- a/phpBB/phpbb/attachment/upload.php +++ b/phpBB/phpbb/attachment/upload.php @@ -246,8 +246,14 @@ class upload { // Move the thumbnail from temp folder to the storage $fp = fopen($destination, 'rb'); + $this->storage->write_stream($destination_name, $fp); - fclose($fp); + + if (is_resource($fp)) + { + fclose($fp); + } + $this->storage->track_file($destination_name); } else diff --git a/phpBB/phpbb/files/filespec_storage.php b/phpBB/phpbb/files/filespec_storage.php index a6870c4a05..49c9618844 100644 --- a/phpBB/phpbb/files/filespec_storage.php +++ b/phpBB/phpbb/files/filespec_storage.php @@ -445,8 +445,14 @@ class filespec_storage try { $fp = fopen($this->filename, 'rb'); + $storage->write_stream($this->destination_file, $fp); - fclose($fp); + + if (is_resource($fp)) + { + fclose($fp); + } + $storage->track_file($this->destination_file); } catch (\phpbb\storage\exception\exception $e)