xcf: Do not overflow int on the setDotsPerMeterX/Y call

This commit is contained in:
Albert Astals Cid 2019-01-27 12:27:03 +01:00
parent b8cb5e322c
commit 3dee6f7c47

View File

@ -1432,8 +1432,14 @@ bool XCFImageFormat::initializeImage(XCFImage &xcf_image)
break; break;
} }
image.setDotsPerMeterX((int)(xcf_image.x_resolution * INCHESPERMETER)); const float dpmx = xcf_image.x_resolution * INCHESPERMETER;
image.setDotsPerMeterY((int)(xcf_image.y_resolution * INCHESPERMETER)); if (dpmx > std::numeric_limits<int>::max())
return false;
const float dpmy = xcf_image.y_resolution * INCHESPERMETER;
if (dpmy > std::numeric_limits<int>::max())
return false;
image.setDotsPerMeterX((int)dpmx);
image.setDotsPerMeterY((int)dpmy);
return true; return true;
} }