LibGfx: Make sure the Painter clip rect is never larger than the target
The new Painter::set_clip_rect(IntRect) API was able to make the clip rect larger than the underlying target bitmap. This was not good, as it could make it possible to draw outside the bitmap memory. Fixes a crash when viewing https://twinings.co.uk/ in the browser. :^)
This commit is contained in:
parent
b4596b48f5
commit
e9078e216d
Notes:
sideshowbarker
2024-07-17 09:49:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e9078e216d
2 changed files with 6 additions and 1 deletions
|
@ -2575,4 +2575,9 @@ void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Painter::set_clip_rect(IntRect const& rect)
|
||||||
|
{
|
||||||
|
state().clip_rect = rect.intersected(m_target->rect());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
IntRect clip_rect() const { return state().clip_rect; }
|
IntRect clip_rect() const { return state().clip_rect; }
|
||||||
void set_clip_rect(IntRect const& rect) { state().clip_rect = rect; }
|
void set_clip_rect(IntRect const&);
|
||||||
|
|
||||||
int scale() const { return state().scale; }
|
int scale() const { return state().scale; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue