prevent crash in crop_image function

This commit is contained in:
GenevensiS
2026-01-19 17:21:42 +01:00
parent ef835e6f46
commit ab4d79a686
14 changed files with 58 additions and 14 deletions
+6 -2
View File
@@ -460,7 +460,9 @@ Image InsertedImage::generate(const Options& opt) {
int inserted_x = offset_x < 0 ? 0 : offset_x;
int inserted_y = offset_y < 0 ? 0 : offset_y;
int width = max(base_x + base_img.GetWidth(), inserted_x + inserted_img.GetWidth());
int height = max(base_y + base_img.GetHeight(), inserted_y + inserted_img.GetHeight());
int height = max(base_y + base_img.GetHeight(), inserted_y + inserted_img.GetHeight());
if (width <= 0) throw ScriptError(_ERROR_1_("negative image width", "insert_image"));
if (height <= 0) throw ScriptError(_ERROR_1_("negative image height", "insert_image"));
UInt size = width * height;
Image img = wxImage(width, height, false);
img.InitAlpha();
@@ -496,7 +498,9 @@ bool InsertedImage::operator == (const GeneratedImage& that) const {
// ----------------------------------------------------------------------------- : CropImage
Image CropImage::generate(const Options& opt) {
Image CropImage::generate(const Options& opt) {
if (width <= 0) throw ScriptError(_ERROR_1_("negative image width", "crop_image"));
if (height <= 0) throw ScriptError(_ERROR_1_("negative image height", "crop_image"));
UInt size = width * height;
Image img = wxImage(width, height, false);
img.InitAlpha();