Bug 19206

Summary: perf/cairo-perf-graph-files.c:322: Mismatching allocation and deallocation: id
Product: cairo Reporter: dvice_null
Component: generalAssignee: Carl Worth <cworth>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: 1.9.1   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description dvice_null 2008-12-20 10:51:19 UTC
I found this from latest git version.

In file perf/cairo-perf-graph-files.c:322: 
Variable id is allocated with:
char *id = g_malloc (len + 1);

And later released:
free (id);

"It's important to match g_malloc() with g_free(), plain malloc() with free(), and (if you're using C++) new with delete and new[] with delete[]. Otherwise bad things can happen, since these allocators may use different memory pools (and new/delete call constructors and destructors)."
http://library.gnome.org/devel/glib/stable/glib-Memory-Allocation.html

ps. The version drop down list does not have "git" or similar option for bugs found from the very latest source files. 

This bug was found using cppcheck: http://cppcheck.wiki.sourceforge.net/
Comment 1 Chris Wilson 2008-12-20 11:16:22 UTC
Fixed locally, will push in next batch.

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.