From 7858871ed4c85b55d28b5660d1b1aa7182a9d611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= Date: Wed, 3 May 2023 18:54:17 +0200 Subject: [PATCH] DrawState: disable drawing when clipping to an invalid rect An invalid rect would mean an empty area to clip to. Its inverse would be an infinite area with no holes. Fixes #18395. Change-Id: I5c739149e539ab63e9aaab6e8716aa73e3ee9d2f Reviewed-on: https://review.haiku-os.org/c/haiku/+/6406 Reviewed-by: waddlesplash Tested-by: Commit checker robot Reviewed-by: John Scipione --- src/servers/app/DrawState.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/servers/app/DrawState.cpp b/src/servers/app/DrawState.cpp index 2d6aa75fd8..a169684b17 100644 --- a/src/servers/app/DrawState.cpp +++ b/src/servers/app/DrawState.cpp @@ -474,8 +474,15 @@ DrawState::GetCombinedClippingRegion(BRegion* region) const bool DrawState::ClipToRect(BRect rect, bool inverse) { - if (!rect.IsValid()) + if (!rect.IsValid()) { + if (!inverse) { + if (!fClippingRegion.IsSet()) + fClippingRegion.SetTo(new(nothrow) BRegion()); + else + fClippingRegion->MakeEmpty(); + } return false; + } if (!fCombinedTransform.IsIdentity()) { if (fCombinedTransform.IsDilation()) {