Check return of fopen() before using it

Fix #9968
This commit is contained in:
Joas Schilling 2014-08-04 17:53:06 +02:00
parent f4c7e3c1e9
commit 303f6da76f
1 changed files with 8 additions and 5 deletions

View File

@ -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)) {