From 3d0a52321791309e06843123a460fd9ad24d89c0 Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Mon, 8 Jun 2015 15:10:29 +0200 Subject: [PATCH] Make sure we have a resource before measuring its size --- lib/private/image.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/private/image.php b/lib/private/image.php index 54e5ef7cad..fad0b53cb4 100644 --- a/lib/private/image.php +++ b/lib/private/image.php @@ -982,10 +982,14 @@ class OC_Image implements \OCP\IImage { * @return bool */ public function scaleDownToFit($maxWidth, $maxHeight) { + if (!$this->valid()) { + $this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core')); + return false; + } $widthOrig = imageSX($this->resource); $heightOrig = imageSY($this->resource); - if ($widthOrig > $maxWidth || $heightOrig >$maxHeight) { + if ($widthOrig > $maxWidth || $heightOrig > $maxHeight) { return $this->fitIn($maxWidth, $maxHeight); }