tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

21-quartz-surface-leak.patch (1447B)


      1 # HG changeset patch
      2 # User Jonathan Kew <jkew@mozilla.com>
      3 # Date 1714678834 -3600
      4 #      Thu May 02 20:40:34 2024 +0100
      5 # Node ID 92c20a5fcddecdc04b4c05ecbfa7fcc64e78ea4e
      6 # Parent  7378b3133191c988cfd1bd3e3f2b615140d79d33
      7 Bug 1892913 - patch 19 - Don't prematurely clear cairo_quartz_image_surface_t's imageSurface field, it still needs to hold a reference to the wrapped image surface.
      8 
      9 Without this, we end up leaking the DataSourceSurfaceRawData that backs the
     10 quartz image surface created during surface-pattern rendering, because the
     11 imageSurface pointer holds a strong reference and then gets cleared without
     12 releasing it.
     13 
     14 diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     15 --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
     16 +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     17 @@ -759,7 +759,12 @@ static cairo_status_t
     18 
     19     if (acquired) {
     20 	_cairo_surface_release_source_image (source, image_surface->imageSurface, image_extra);
     21 -	image_surface->imageSurface = NULL;
     22 +	/* If source itself is an image surface, _cairo_surface_release_source_image
     23 +	   does not release it, and image_surface->imageSurface still owns a reference
     24 +	   to it. So we don't clear that field here; _cairo_quartz_image_surface_finish
     25 +	   will take care of it. */
     26 +	if (source->type != CAIRO_SURFACE_TYPE_IMAGE)
     27 +	    image_surface->imageSurface = NULL;
     28     }
     29     cairo_surface_destroy (&image_surface->base);