From 3dee6f7c4764dbe5d6da733729e56de9ccaeeff8 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sun, 27 Jan 2019 12:27:03 +0100 Subject: [PATCH] xcf: Do not overflow int on the setDotsPerMeterX/Y call --- src/imageformats/xcf.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/imageformats/xcf.cpp b/src/imageformats/xcf.cpp index 758b65e..b0c6028 100644 --- a/src/imageformats/xcf.cpp +++ b/src/imageformats/xcf.cpp @@ -1432,8 +1432,14 @@ bool XCFImageFormat::initializeImage(XCFImage &xcf_image) break; } - image.setDotsPerMeterX((int)(xcf_image.x_resolution * INCHESPERMETER)); - image.setDotsPerMeterY((int)(xcf_image.y_resolution * INCHESPERMETER)); + const float dpmx = xcf_image.x_resolution * INCHESPERMETER; + if (dpmx > std::numeric_limits::max()) + return false; + const float dpmy = xcf_image.y_resolution * INCHESPERMETER; + if (dpmy > std::numeric_limits::max()) + return false; + image.setDotsPerMeterX((int)dpmx); + image.setDotsPerMeterY((int)dpmy); return true; }