From 303f6da76fbddc31540a129819356a69b7589496 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Aug 2014 17:53:06 +0200 Subject: [PATCH] Check return of fopen() before using it Fix #9968 --- lib/private/preview.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/private/preview.php b/lib/private/preview.php index aeb9806904..cc15ab84fe 100755 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -477,12 +477,15 @@ class Preview { $cached = $this->isCached($fileId); if ($cached) { $stream = $this->userView->fopen($cached, 'r'); - $image = new \OC_Image(); - $image->loadFromFileHandle($stream); - $this->preview = $image->valid() ? $image : null; + $this->preview = null; + if ($stream) { + $image = new \OC_Image(); + $image->loadFromFileHandle($stream); + $this->preview = $image->valid() ? $image : null; - $this->resizeAndCrop(); - fclose($stream); + $this->resizeAndCrop(); + fclose($stream); + } } if (is_null($this->preview)) {