Refuse to scale an image which is too large to be properly handled

...by the wxIMAGE_QUALITY_NEAREST resampling algorithm. See #18550
This commit is contained in:
Paul Cornett
2019-10-30 21:17:14 -07:00
parent 349e73994b
commit 26701fd017

View File

@@ -505,6 +505,12 @@ wxImage::Scale( int width, int height, wxImageResizeQuality quality ) const
wxImage wxImage::ResampleNearest(int width, int height) const
{
wxImage image;
const unsigned long old_width = M_IMGDATA->m_width;
const unsigned long old_height = M_IMGDATA->m_height;
wxCHECK_MSG(old_width <= (ULONG_MAX >> 16) &&
old_height <= (ULONG_MAX >> 16), image, "image dimension too large");
image.Create( width, height, false );
unsigned char *data = image.GetData();
@@ -526,8 +532,6 @@ wxImage wxImage::ResampleNearest(int width, int height) const
}
}
const unsigned long old_height = M_IMGDATA->m_height;
const unsigned long old_width = M_IMGDATA->m_width;
const unsigned long x_delta = (old_width << 16) / width;
const unsigned long y_delta = (old_height << 16) / height;