vcl/headless/CairoCommon.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit e77beab92dfe1136a59c99af6571de6eae9f7e12
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Nov 4 13:16:34 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Nov 4 17:22:59 2022 +0100

    ofz#53034 Null-dereference
    
    Change-Id: I3be4f2b976b64a2f592eeef9802e6cf8dd15341b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142278
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 8f11fdbd9b6c..a25c508f39ce 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -597,12 +597,20 @@ void CairoCommon::clipRegion(cairo_t* cr, const 
vcl::Region& rClipRegion)
     }
     if (!aRectangles.empty())
     {
+        bool bEmpty = true;
         for (auto const& rectangle : aRectangles)
         {
+            if (rectangle.GetWidth() <= 0 || rectangle.GetHeight() <= 0)
+            {
+                SAL_WARN("vcl.gdi", "bad clip rect of: " << rectangle);
+                continue;
+            }
             cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), 
rectangle.GetWidth(),
                             rectangle.GetHeight());
+            bEmpty = false;
         }
-        cairo_clip(cr);
+        if (!bEmpty)
+            cairo_clip(cr);
     }
 }
 

Reply via email to