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; }