fix(preview-generator): Throw exception before dividing by zero when generating previews

If the maximum preview generated gives some kind of invalid IImage, it's dimentions and filename can be set to zero.
And then later we do a division by zero to keep the aspect ratio of the previews.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-02-13 16:47:26 +01:00
parent 8f0849a317
commit e60888d988
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -170,6 +170,10 @@ class Generator {
[$maxWidth, $maxHeight] = $this->getPreviewSize($maxPreview, $previewVersion);
if ($maxWidth <= 0 || $maxHeight <= 0) {
throw new NotFoundException('The maximum preview sizes are zero or less pixels');
}
$preview = null;
foreach ($specifications as $specification) {