From 26701fd0177a21673f5f93d2c25f78ea2010dc3d Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 30 Oct 2019 21:17:14 -0700 Subject: [PATCH] Refuse to scale an image which is too large to be properly handled ...by the wxIMAGE_QUALITY_NEAREST resampling algorithm. See #18550 --- src/common/image.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/image.cpp b/src/common/image.cpp index f21b0318f2..3ca0f640b9 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -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;