diff --git a/lib/private/Preview/Bitmap.php b/lib/private/Preview/Bitmap.php index b63c5fe86783..23694afd4c25 100644 --- a/lib/private/Preview/Bitmap.php +++ b/lib/private/Preview/Bitmap.php @@ -49,9 +49,10 @@ public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) { } catch (\Exception $e) { Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), Util::ERROR); return false; + } finally { + fclose($stream); } - fclose($stream); //new bitmap image object $image = new \OC_Image(); diff --git a/lib/private/Preview/SVG.php b/lib/private/Preview/SVG.php index ae1e85264182..e860588a6416 100644 --- a/lib/private/Preview/SVG.php +++ b/lib/private/Preview/SVG.php @@ -42,10 +42,12 @@ public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) { $svg = new \Imagick(); $svg->setBackgroundColor(new \ImagickPixel('transparent')); - $content = stream_get_contents($file->fopen('r')); + $stream = $file->fopen('r'); + $content = stream_get_contents($stream); if (substr($content, 0, 5) !== '' . $content; } + fclose($stream); // Do not parse SVG files with references if (stripos($content, 'xlink:href') !== false) { diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index a996d1ffe279..a07ca5864fd1 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -40,8 +40,9 @@ public function getMimeType() { * {@inheritDoc} */ public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) { - $content = $file->fopen('r'); - $content = stream_get_contents($content,3000); + $stream = $file->fopen('r'); + $content = stream_get_contents($stream,3000); + fclose($stream); //don't create previews of empty text files if(trim($content) === '') {