summaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-11 10:08:24 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-11 10:08:24 +0200
commite2c4a0cecdfd127a1e985d71e92790ed5127ee04 (patch)
tree877194ced5a50aa9d3dec1ec80aae00a8daab361 /lib/private/files
parentc6f65a3c79d11b7040cdc90b75318ef8560c1f98 (diff)
parent178ad23d80406e72ddf55d08e318fb124ab3013a (diff)
downloadnextcloud-server-e2c4a0cecdfd127a1e985d71e92790ed5127ee04.tar.gz
nextcloud-server-e2c4a0cecdfd127a1e985d71e92790ed5127ee04.zip
Merge pull request #23860 from owncloud/followup-23304-opening-empty-file
Correctly return an empty string for empty files
Diffstat (limited to 'lib/private/files')
-rw-r--r--lib/private/files/storage/local.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 9f093ce048a..25b202af5f8 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -177,9 +177,15 @@ class Local extends \OC\Files\Storage\Common {
public function file_get_contents($path) {
// file_get_contents() has a memory leak: https://bugs.php.net/bug.php?id=61961
- $filename = $this->getSourcePath($path);
- $handle = fopen($filename,'rb');
- $content = fread($handle, filesize($filename));
+ $fileName = $this->getSourcePath($path);
+
+ $fileSize = filesize($fileName);
+ if ($fileSize === 0) {
+ return '';
+ }
+
+ $handle = fopen($fileName,'rb');
+ $content = fread($handle, $fileSize);
fclose($handle);
return $content;
}