Improve error handling in GDImageAdapter::loadFile()
authorMarcel Werk <burntime@woltlab.com>
Sun, 31 Oct 2021 17:26:19 +0000 (18:26 +0100)
committerMarcel Werk <burntime@woltlab.com>
Sun, 31 Oct 2021 17:26:19 +0000 (18:26 +0100)
Closes #4413

wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php

index 6e654a8aaaf33abd6dd0391bef86a2f08d55b6d8..b53bebbaf6fead0ab016c2b74b5f2990ffb48a42 100644 (file)
@@ -99,7 +99,11 @@ class GDImageAdapter implements IImageAdapter, IWebpImageAdapter
 
         switch ($this->type) {
             case \IMAGETYPE_GIF:
-                $this->image = \imagecreatefromgif($file);
+                // suppress warnings and properly handle errors
+                $this->image = @\imagecreatefromgif($file);
+                if ($this->image === false) {
+                    throw new SystemException("Could not read gif image '" . $file . "'.");
+                }
                 break;
 
             case \IMAGETYPE_JPEG: