[cairo-commit] 2 commits - src/cairo-default-context.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 22 18:36:35 UTC 2021


 src/cairo-default-context.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit ee90ce594678ff227a28cdf1d9b55b7c3494f49c
Merge: 76aed3a5e 36f5dee47
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Jan 22 18:36:33 2021 +0000

    Merge branch 'set-source-surface-leak' into 'master'
    
    Plug a memory leak in an error case
    
    See merge request cairo/cairo!115

commit 36f5dee473010a450ff49c1bc34bca9edd4ff539
Author: Matthias Clasen <mclasen at redhat.com>
Date:   Fri Jan 22 12:24:30 2021 -0500

    Plug a memory leak in an error case
    
    GTK has a testcase that tests the error when creating
    an oversize image, and asan tells me that it triggers
    a memory leak in cairo:
    
    Direct leak of 160 byte(s) in 1 object(s) allocated from:
        #0 0x7f1122755667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
        #1 0x7f1120cc83e8 in _cairo_pattern_create_solid ../src/cairo-pattern.c:607
        #2 0x7f1120cc8487 in _cairo_pattern_create_in_error ../src/cairo-pattern.c:630
        #3 0x7f1120cc87cb in INT_cairo_pattern_create_for_surface ../src/cairo-pattern.c:736
        #4 0x7f1120c1f1c7 in _cairo_default_context_set_source_surface ../src/cairo-default-context.c:327
        #5 0x7f1120d8386a in INT_cairo_set_source_surface ../src/cairo.c:982
        #6 0x7f1121d005a2 in gdk_cairo_set_source_pixbuf ../gdk/gdkcairo.c:234
        #7 0x401427 in test_set_source_big_pixbuf ../testsuite/gdk/cairo.c:23

diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index 95b5f6b77..d2c9cae10 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -325,8 +325,11 @@ _cairo_default_context_set_source_surface (void *abstract_cr,
     _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black);
 
     pattern = cairo_pattern_create_for_surface (surface);
-    if (unlikely (pattern->status))
-	return pattern->status;
+    if (unlikely (pattern->status)) {
+        status = pattern->status;
+        cairo_pattern_destroy (pattern);
+        return status;
+    }
 
     cairo_matrix_init_translate (&matrix, -x, -y);
     cairo_pattern_set_matrix (pattern, &matrix);


More information about the cairo-commit mailing list