From 496a9a40a1853376d877a017a2b6b79b6d6b5f71 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 23 Aug 2023 23:03:43 -0700 Subject: [PATCH] Avoid division-by-zero in wxImage::Paste() See #23791 --- src/common/image.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/image.cpp b/src/common/image.cpp index 2e5108fc10..98037f9c39 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1741,6 +1741,14 @@ wxImage::Paste(const wxImage & image, int x, int y, float light_left = (alpha_target_data[i] / 255.0f) * (1.0f - source_alpha); float result_alpha = source_alpha + light_left; alpha_target_data[i] = (unsigned char)((result_alpha * 255) + 0.5f); + if (result_alpha <= 0) + { + int c = 3 * i; + target_data[c++] = 0; + target_data[c++] = 0; + target_data[c] = 0; + continue; + } for (int c = 3 * i; c < 3 * (i + 1); c++) { target_data[c] =