diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-04-08 14:50:42 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-04-08 15:08:52 +0200 |
commit | d2c11a35b7d45bde9f661eb4155109a375642a1a (patch) | |
tree | 32cbd2a3fa7e7947b848465e8c41d1af7bca17f8 /lib | |
parent | 7fdac35654c9a440d33ca0b4b0d8a469cd524dbf (diff) | |
download | nextcloud-server-d2c11a35b7d45bde9f661eb4155109a375642a1a.tar.gz nextcloud-server-d2c11a35b7d45bde9f661eb4155109a375642a1a.zip |
Correctly return an empty string for empty files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/storage/local.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index b6d0ec3fb34..b0918c82f98 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; } |