[BUGFIX] Prevent division by 0 when using image file without dimensions 50/51750/5
authorFrans Saris <franssaris@gmail.com>
Sun, 19 Feb 2017 09:50:48 +0000 (10:50 +0100)
committerSascha Egerer <sascha@sascha-egerer.de>
Sun, 19 Feb 2017 23:35:02 +0000 (00:35 +0100)
Resolves: #79902
Releases: master
Change-Id: I42a126369108434e33d3b00d4fe6b556592dc2c9
Reviewed-on: https://review.typo3.org/51750
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
typo3/sysext/core/Classes/Imaging/ImageManipulation/Area.php

index 54388dd..0c1a632 100644 (file)
@@ -128,11 +128,18 @@ class Area
      */
     public function makeRelativeBasedOnFile(FileInterface $file)
     {
+        $width = $file->getProperty('width');
+        $height = $file->getProperty('height');
+
+        if (empty($width) || empty($height)) {
+            return self::createEmpty();
+        }
+
         return new self(
-            $this->x / $file->getProperty('width'),
-            $this->y / $file->getProperty('height'),
-            $this->width / $file->getProperty('width'),
-            $this->height / $file->getProperty('height')
+            $this->x / $width,
+            $this->y / $height,
+            $this->width / $width,
+            $this->height / $height
         );
     }