From 7642633551d94e1cd3a548dcb5637ac14d414532 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 19 Aug 2021 17:29:44 +0200 Subject: [PATCH] SGIImage::writeImage: Properly fail if the image is too big --- src/imageformats/rgb.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/imageformats/rgb.cpp b/src/imageformats/rgb.cpp index a04bc33..20f2f43 100644 --- a/src/imageformats/rgb.cpp +++ b/src/imageformats/rgb.cpp @@ -681,9 +681,16 @@ bool SGIImage::writeImage(const QImage &image) return false; } + const int w = img.width(); + const int h = img.height(); + + if (w > 65536 || h > 65536) { + return false; + } + _bpc = 1; - _xsize = img.width(); - _ysize = img.height(); + _xsize = w; + _ysize = h; _pixmin = ~0u; _pixmax = 0; _colormap = NORMAL;