From 0959cdb4e04beb1e473f4c86d45687020ffb4d03 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Mar 2021 14:03:06 +0100 Subject: [PATCH] Check for memory allocation failure in all wxImage::ResampleXXX() This was previously done in ResampleNearest() but not in all the other variants, so add the checks there too to avoid crashing when trying to use too big image sizes. Closes #19119. --- src/common/image.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/image.cpp b/src/common/image.cpp index 85ab31c7c2..78fe5b82a3 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -635,6 +635,8 @@ wxImage wxImage::ResampleBox(int width, int height) const unsigned char* dst_data = ret_image.GetData(); unsigned char* dst_alpha = NULL; + wxCHECK_MSG( dst_data, ret_image, wxS("unable to create image") ); + if ( src_alpha ) { ret_image.SetAlpha(); @@ -782,6 +784,8 @@ wxImage wxImage::ResampleBilinear(int width, int height) const unsigned char* dst_data = ret_image.GetData(); unsigned char* dst_alpha = NULL; + wxCHECK_MSG( dst_data, ret_image, wxS("unable to create image") ); + if ( src_alpha ) { ret_image.SetAlpha(); @@ -961,6 +965,8 @@ wxImage wxImage::ResampleBicubic(int width, int height) const unsigned char* dst_data = ret_image.GetData(); unsigned char* dst_alpha = NULL; + wxCHECK_MSG( dst_data, ret_image, wxS("unable to create image") ); + if ( src_alpha ) { ret_image.SetAlpha();