Bug 7100

Summary: XKeysymToString causes leaks for lookups of unnamed keys in Unicode range
Product: xorg Reporter: Alan Coopersmith <alan.coopersmith>
Component: Lib/XlibAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED INVALID QA Contact: Xorg Project Team <xorg-team>
Severity: major    
Priority: high CC: kimmo.hamalainen
Version: 7.0 (2005.12)Keywords: love
Hardware: All   
OS: All   
Whiteboard: 2011BRB_Reviewed
i915 platform: i915 features:

Description Alan Coopersmith 2006-06-03 00:27:26 UTC
The XKeysymToString man page says:
     The returned string is in a static area and must not be modified.

so no well-behaved other library or program ever calls free() on the returned
value.   However, if XKeysymToString can't find a keysym name and has to make
one up for a keycode in the range 0x01000100 - 0x0110ffff, then it mallocs a
new string, writes in a name and returns it.   Since it doesn't do anything
else, and the calling program doesn't know it needs to clean up, it will leak.
If it looks up the keysym multiple times, it will allocate new memory each time
and leak more memory each time.

Xlib should probably store the newly created name in it's hash table with other
keysyms, so that future lookups get the same pointer each time.
Comment 1 Daniel Stone 2007-02-27 01:32:21 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 2 Julien Cristau 2009-02-17 06:33:22 UTC
*** Bug 20063 has been marked as a duplicate of this bug. ***
Comment 3 Jeremy Huddleston Sequoia 2011-10-03 16:46:47 UTC
Bumping priority since this is a memory leak.  Pulling it into my queue.  This 
should be fairly straight forward to implement for anyone wanting to "jump in" 
to X11.
Comment 4 Adam Jackson 2018-06-12 19:07:26 UTC
Mass closure: This bug has been untouched for more than six years, and is not
obviously still valid. Please reopen this bug or file a new report if you continue to experience issues with current releases.

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.