Bug 89481 - XCreateIC() leaks name and class strings
Summary: XCreateIC() leaks name and class strings
Status: RESOLVED MOVED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xlib (show other bugs)
Version: unspecified
Hardware: Other All
: medium minor
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-07 06:58 UTC by Andrew Church
Modified: 2018-08-10 20:11 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Andrew Church 2015-03-07 06:58:00 UTC
In libX11-1.6.2, when creating an input context, the name and class strings passed with XNResourceName and XNResourceClass are copied, but the copies are not freed when XDestroyIC() is called on the resulting input context:

main() {
    /* ... */
    XIC ic = XCreateIC(x11_im,
                       XNClientWindow, window,
                       XNFocusWindow, window,
                       XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                       XNResourceName, "foobar",  // Leaked.
                       XNResourceClass, "foobar",  // Leaked.
                       NULL);
    XDestroyIC(ic);
    /* ... */
}

$ valgrind --leak-check=full ./test
[...]
==8402== 14 bytes in 2 blocks are definitely lost in loss record 13 of 94
==8402==    at 0x4C2B960: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8402==    by 0x79392D1: strdup (in /lib64/libc-2.20.so)
==8402==    by 0x69F22E6: ??? (in /usr/lib64/libX11.so.6.3.0)
==8402==    by 0x69F3114: _XimSetICValueData (in /usr/lib64/libX11.so.6.3.0)
==8402==    by 0x69EE628: _XimLocalCreateIC (in /usr/lib64/libX11.so.6.3.0)
==8402==    by 0x69D3AB4: XCreateIC (in /usr/lib64/libX11.so.6.3.0)

Set to severity "minor" since the leak size is small and most programs will probably not call XCreateIC() and XDestroyIC() over and over.
Comment 1 GitLab Migration User 2018-08-10 20:11:00 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/xorg/lib/libx11/issues/43.


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.