From: Marcel Werk Date: Sun, 31 Oct 2021 17:26:19 +0000 (+0100) Subject: Improve error handling in GDImageAdapter::loadFile() X-Git-Tag: 5.5.0_Alpha_1~341 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=28ab4fee0a600a7e7458fe3a6e702ed8ac94f002;p=GitHub%2FWoltLab%2FWCF.git Improve error handling in GDImageAdapter::loadFile() Closes #4413 --- diff --git a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php index 6e654a8aaa..b53bebbaf6 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php @@ -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: