diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index ba2c94e851..2567ba288e 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -137,6 +137,7 @@
[Fix] Add poster-name to moderator-log when deleting post/topic (Bug #46225 - Patch by nickvergessen)
[Fix] "Report details" link broken in MCP (Bug #46975 - Patch by nickvergessen)
[Fix] Resolve accesskey conflicts in prosilver. (Bug #44685 - Patch by bantu)
+ [Fix] Check if template file is empty before trying to read from it. (Bug #47345 - Patch by bantu)
[Change] Change the data format of the default file ACM to be more secure from tampering and have better performance.
[Change] Add index on log_time to the log table to prevent slowdown on boards with many log entries. (Bug #44665 - Patch by bantu)
[Change] Template engine now permits to a limited extent variable includes.
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 16b1852cd6..ab9ddc0b6f 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -2556,9 +2556,22 @@ parse_css_file = {PARSE_CSS_FILE}
{
trigger_error("Could not open {$phpbb_root_path}styles/$template_path$pathfile$file", E_USER_ERROR);
}
- $template_data = fread($fp, filesize("{$phpbb_root_path}styles/$template_path$pathfile$file"));
+
+ $filesize = filesize("{$phpbb_root_path}styles/$template_path$pathfile$file");
+
+ if ($filesize)
+ {
+ $template_data = fread($fp, $filesize);
+ }
+
fclose($fp);
+ if (!$filesize)
+ {
+ // File is empty
+ continue;
+ }
+
if (preg_match_all('##is', $template_data, $matches))
{
foreach ($matches[1] as $match)