From 5b617a6cc1fe6374323dc22a5b5ee127de632284 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sat, 22 Feb 2025 09:02:01 +0100 Subject: [PATCH] Fix "Fl_RGB_Image::draw() seg faults when offset is too big" - cont'd (#1211) --- src/Fl_Image.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index d5fdeca5d..019e0c664 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -727,7 +727,7 @@ static void crect_intersect(rectangle_int_t *to, rectangle_int_t *with) { void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { float s = fl_graphics_driver->scale(); - if (s != int(s) && (cx || cy || WP != w() || HP != h())) { + if (s != int(s) && (cx || cy || WP != w() || HP != h()) && w() == data_w() && h() == data_h()) { // See issue #1128: clipping to a part of the image while the scaling // has a fractional value creates problems rectangle_int_t r1 = { XP-cx, YP-cy, w(), h() }; @@ -737,7 +737,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { // After this, r1.x,r1.y = position of top-left of drawn image part; // r1.width,r1.height = size of drawn image part, in FLTK units; // fl_max(cx, 0),fl_max(cy, 0) = top-left of drawn part in image. - int l = (ld() ? ld() : d() * data_w()); + int l = (ld() ? ld() : d() * w()); const uchar *p = array + fl_max(cy, 0) * l + fl_max(cx, 0) * d(); fl_graphics_driver->draw_image(p, r1.x, r1.y, r1.width, r1.height, d(), l); } else -- GitLab