Bug 91396

Summary: Memory leak in cairo-script-surface
Product: cairo Reporter: Massimo <sixtysix>
Component: generalAssignee: Chris Wilson <chris>
Status: RESOLVED MOVED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: plug a memory leak
script: Plug a memory leak using recording surfaces and vector glyph

Description Massimo 2015-07-19 14:38:00 UTC
Created attachment 117248 [details]
plug a memory leak

The bug is that in '_emit_recording_surface_pattern' the current cr is
saved on the stack in 'old_cr':

http://cgit.freedesktop.org/cairo/tree/src/cairo-script-surface.c#n1173

if replaying the recording surface 'emit_source' is called it is possible
that the 'current_source' member of surface->cr is finished and in its
place is copied the new source, (for surface_patterns this means that the new
source surface ref count is incremented):

http://cgit.freedesktop.org/cairo/tree/src/cairo-script-surface.c#n1741
    
but exiting the recursion 'old_cr' is assigned/raw-copied onto surface->cr and
current_source is overwritten without the matching ref count decrement.
    
compiling cairo with -fsanitize=address Gcc option and running

(cd test; CAIRO_TEST_TARGET=recording ./cairo-test-suite -f user-font-mask )

the report ends with:
... 
SUMMARY: AddressSanitizer: 7632 byte(s) leaked in 27 allocation(s).
Comment 1 Chris Wilson 2015-07-19 15:08:03 UTC
Created attachment 117249 [details] [review]
script: Plug a memory leak using recording surfaces and vector glyph

Hah, I wrote an almost identical patch!
Comment 2 GitLab Migration User 2018-08-25 13:39:54 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/124.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.