mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 00:51:33 +00:00
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
|
@ -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; }
|
||||
void set_clip_rect(IntRect const& rect) { state().clip_rect = rect; }
|
||||
void set_clip_rect(IntRect const&);
|
||||
|
||||
int scale() const { return state().scale; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue