Bug 19768 - cairo/util/malloc-stats.c:90: Memory leak: name
Summary: cairo/util/malloc-stats.c:90: Memory leak: name
Status: RESOLVED WONTFIX
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.9.1
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-27 13:53 UTC by dvice_null
Modified: 2009-01-27 14:04 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description dvice_null 2009-01-27 13:53:00 UTC
From latest git

In file cairo/util/malloc-stats.c:90
Variable "name" is leaking memory I think. strdup allocates memory, but later if p is not null, the pointer location is moved, which would make it unlikely for the caller to be able to release the memory correctly. 

I didn't follow the execution path to see what is eventually done to the returned value, is it freed with free() or not and not even sure what happens if you call free() for a pointer that is in the middle of allocated memory. 

	name = strdup (strings[0]);

	p = strchr (name, '\t');
	if (p)
		name = p + 1;

	free (strings);

	return name;
}

This bug was found using cppcheck: http://cppcheck.wiki.sourceforge.net/
Comment 1 Chris Wilson 2009-01-27 14:04:15 UTC
The strdup()ed memory is kept until process termination. I'm inclined to keep the lightweight malloc profiler as simple as possible (and no simpler).


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.